Build a Palindrome Checker Project - Build a Palindrome Checker

Tell us what’s happening:

hello..please i’m stucked again and i think the spaces and added special characters are what causing the problem for me, please am i not on the right path? i thought the negative regex would fix it but it seem i’m missing on something

Your code so far

<!-- file: index.html -->
<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="utf-8">
    <meta name="viewport" content ="width=device-width, initial-scale = 1.0">
    <link rel="stylesheet" href="styles.css"/>
    <title>palindromes</title>
  </head>
  <body>
    <input id="text-input">
    <button id="check-btn">check</button>
    <div><span id="result"></span></div>

    <script src="script.js"></script>
  </body>



</html>
/* file: script.js */
const textInput = document.getElementById("text-input");
const button = document.getElementById("check-btn");
const result = document.getElementById("result");
const replace = textInput.value.replace(/[^a-zA-Z0-9]/g, "");

button.addEventListener("click", () => {
  if(textInput.value === ""){
    alert("Please input a value")
  };

  const text = textInput.value.trim();
   const sure =[...textInput.value].reverse().join("").replace(/[^a-zA-Z0-9]/g,"");
   
  
   
   if (sure === text){
     result.innerText = `${textInput.value} is a palindrome`;
   }
   else {
     result.innerText = `${textInput.value} is not a palindrome`;
   }
   

})



/* file: styles.css */
#check-btn{

}

Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/132.0.0.0 Safari/537.36 OPR/117.0.0.0

Challenge Information:

Build a Palindrome Checker Project - Build a Palindrome Checker

look at what you are doing, you are using replace to create sure, but what about text?
add a console.log(sure, text) rigth above the if statement, are they what you expect?

1 Like

God bless you, thanks as well