hallo.
i need a help.
I don’t understand why I can’t resolve these two instructions
-
When the
#text-inputelement contains the text1 eye for of 1 eye.and the#check-btnelement is clicked, the#resultelement should contain the text"1 eye for of 1 eye. is not a palindrome". -
When the
#text-inputelement contains the text0_0 (: /-\ :) 0-0and the#check-btnelement is clicked, the#resultelement should contain the text"0_0 (: /-\ :) 0-0 is a palindrome".
I wirte mx conde under.
could you give me a advice
const textInput = document.getElementById("text-input");
const checkButton = document.getElementById("check-btn");
const result = document.getElementById("result");
checkButton.addEventListener("click", () => {
const textInputValue = textInput.value.trim().toLowerCase().replace(/[^a-zA-Z]/g, "");
const reverseText = textInputValue.split("").reverse().join("");
if (textInputValue === "") {
alert('Please input a value');
} else if (textInputValue === reverseText.replace(/[^a-zA-Z]/g, ""){
result.innerText = textInput.value + " is a palindrome";
} else {
result.innerText = textInput.value + " is not a palindrome";
}
});