const checkButton = document.getElementById(“check-btn”);
const textInput = document.getElementById(“text-input”);
const result = document.getElementById(“result”);
const str = textInput.innerText.toLowerCase().replace(/^a-z0-9/g, “”);
function noInput() {
if (textInput.innerText === “”) {
alert(“Please input a value”);
result.innerText = “”;
}
}
function palindrome() {
if (str === str.split(‘’).reverse().join(‘’)) {
result.innerText = ${textInput.innerText} is a palindrome
;
} else {
result.innerText = ${textInput.innerText} is not a palindrome
;
}
}
checkButton.addEventListener(“click”, palindrome);
checkButton.addEventListener(“click”, noInput);
I’ve been trying for days to figure this out. The way I have it, it gives me the alert but it gives me one even if I do have a value and I can’t make my result appear when I have a value.