Build a Palindrome Checker Project - Build a Palindrome Checker

please check step 61 again

ah. below all the tests I get:

Please input a value
[TypeError: Cannot read properties of undefined (reading ‘trim’)]
Please input a value
Please input a value
Please input a value
Please input a value
Please input a value
Please input a value
Please input a value
Please input a value
Please input a value
Please input a value
Please input a value
Please input a value
Please input a value
Please input a value

oop there it is. i looked at the final code and just breezed right over that line, and ctrl-F didn’t find it! thank you for showing me

Blockquote
const inputText = document.getElementById(“text-input”).value;
const checkButton = document.getElementById(“check-btn”);
const resultOutput = document.getElementById(“result”);
checkButton.addEventListener(“click”, () => {
if (inputText === “”) {
alert(“Please input a value”);
// console.log(“Please input a value”);
} else {
const cleanInput = inputText.toLowerCase.split(“”).replace(/[^0-9a-zA-Z]/g, “”)
const testString = cleanInput.reverse();
if (testString === cleanInput) {
resultOutput.innerText = ${inputText} is a Palindrome;
console.log(${inputText} is a Palindrome);
} else {
resultOutput.innerText = ${inputText} is not a Palindrome;
console.log(${inputText} is not a Palindrome);
}
}
})

Ok, so i fixed the alert thing (thank you again) and now, no matter what i put into the text box, that’s what pops up. So good news- I’ve gotten closer to the real problem! bad news- no matter what goes in the text box, it’s not getting read. but now i know where to take a closer look

Try wrapping the content in back ticks.

Remove the console.logs for the tests.

wrap which content?

i removed the .value from the input text variable just to see if that changed anything, and it gave me an error code “Uncaught TypeError: Cannot read properties of undefined (reading ‘split’)” so that may have been a backwards step

const checkButton = document.getElementById(“check-btn”);
const resultOutput = document.getElementById(“result”);
let textualFeelings = document.getElementById(“text-input”);

checkButton.addEventListener(“click”, () => {
let inputText = textualFeelings.value;
if (inputText === “”) {
alert(“Please input a value”);
console.log(“Please input a value”);
} else {
const cleanInput = inputText.replace(/[^\da-zA-Z]/g, “”).toLowerCase();
const testString = cleanInput.split(``).reverse().join();

if (testString === cleanInput) {
  resultOutput.innerText = `${inputText} is a Palindrome`;
  console.log(`${inputText} is a Palindrome`);
} else {
  resultOutput.innerText = `${inputText} is not a Palindrome`;
  console.log(`${inputText} is not a Palindrome`);
}

}
})

Ok i fixed it! now it’s not returning all the tests correctly, because it’s looking at spaces and counting them as characters. but I can work it out from here (i hope) (as long as it’s a problem with the regex)

Hi @blake833
These two lines.

those two lines are already in backticks (see the post right before yours)