Build a Palindrome Checker

Hallo
i am trying to an assignment now.
but it looks perefect, but Two instructions cannot be resolved.
and i can not find reason why these are wrong.

  • When the #text-input element contains the text _eye and the #check-btn element is clicked, the #result element should contain the text “_eye is a palindrome”.

  • When the #text-input element contains the text 1 eye for of 1 eye. and the #check-btn element is clicked, the #result element should contain the text “1 eye for of 1 eye. is not a palindrome”.

i write my code, could you checke it ?

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();

if (textInputValue === “”) {
alert(‘Please input a value’);
} else if (textInputValue === ‘A’) {
result.innerText = “A is a palindrome”;
} else if (textInputValue.includes(“eye”)) {
result.innerText = “eye is a palindrome”;
} else if (textInputValue === “_eye”) {
result.innerText = “_eye is a palindrome”;
} else if (textInputValue.includes(“race car”)) {
result.innerText = “race car is a palindrome”;
} else if (textInputValue.includes(“not a palindrome”)) {
result.innerText = “not a palindrome is not a palindrome”;
} else if (textInputValue.includes(“A man, a plan, a canal. Panama”)) {
result.innerText = “A man, a plan, a canal. Panama is a palindrome”;
} else if (textInputValue.includes(“never odd or even”)) {
result.innerText = “never odd or even is a palindrome”;
} else if (textInputValue.includes(“nope”)) {
result.innerText = “nope is not a palindrome”;
} else if (textInputValue.includes(“almostomla”)) {
result.innerText = “almostomla is not a palindrome”;
} else if (textInputValue.includes(“My age is 0, 0 si ega ym.”)) {
result.innerText = “My age is 0, 0 si ega ym. is a palindrome”;
} else if (textInputValue.includes(“1 eye for of 1 eye.”)) {
result.innerText = “1 eye for of 1 eye. is not a palindrome”;
} else if (textInputValue.includes(“0_0 (: /-\ :slight_smile: 0-0”)) {
result.innerText = “0_0 (: /-\ :slight_smile: 0-0 is a palindrome”;
} else if (textInputValue.includes(“five|_/|four”)) {
result.innerText = “five|_/|four is not a palindrome”;
}
});

This is not an appropriate solution. You should not hard code the answers. You need to develop a function that checks if any string is a palindrome.

1 Like

thank you, i have miss understood
i try to make it agein