Palindrome checker not working

i’ve tried multiple solutions from other people who had the same problem but nothing worked

<!DOCTYPE html>
<html lang="en">
  <head>
    <title>Palindrome Checker</title>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <link rel="stylesheet" href="styles.css"></link>
    </head>
    <body>
      <h1>Is it a Palindrome?</h1>
      <!--Main function of the site-->
      <div id="result">
        <p class="instruction">Enter in text to check for a palindrome:</p>
        <div class="button-input">
        <input type="text" id="text-input"></input>
        <button id="check-btn">Check</button>
        </div>
        <div id="result-text">
        </div>
       </div> 
      <div class="PalExpl">
        <p class="ExplText"> A palindrome is a word or sentence that's spelled the same way both forward and backward, ignoring punctuation, case, and spacing. </p>
        </div>
      <!--JS code tag-->
     <script src="script.js"></script>
      </body>
  </html>
const resultText = document.getElementById("result-text");
const buttonCheck = document.getElementById("check-btn");
const inputElement = document.getElementById("text-input");
/*Get the text inside the input*/
function storeInputText(){
/*Turn the text to lower case*/  
  const newLowerText = inputElement.value.toLowerCase();
/*Remove panctuation, space*/
  const newText = newLowerText.replace(/[^a-zA-Z0-9]/g, "");
  return newText;
}

/*Check if text is a palindrom*/
function isPal(text){
  let isPalindrom = true;
  let letterRight = text.length - 1;
  let letterLeft = 0;
  const middle = Math.floor(text.length / 2);
  while(isPalindrom && letterLeft <= middle){
    isPalindrom = text[letterLeft] == text[letterRight]
    letterRight--;
    letterLeft++;
}
return isPalindrom
}
/*Write the result of isPal*/
buttonCheck.addEventListener("click",() => {
const originaleText = inputElement.value;
const text = storeInputText();

if (originaleText == ""){
    alert("Please input a value");
  }else if(isPal(text)) {
    resultText.textContent = `${originaleText} is a palindrome`;
  }else{
    resultText.textContent = `${originaleText} is not a palindrome`;
  }
inputElement.value = "";
})

is this how you write the word?

I’ve edited your post to improve the readability of the code. When you enter a code block into a forum post, please precede it with a separate line of three backticks and follow it with a separate line of three backticks to make it easier to read.

You can also use the “preformatted text” tool in the editor (</>) to add backticks around text.

See this post to find the backtick on your keyboard.
Note: Backticks (`) are not single quotes (').

That was a dumb mistake, but even after correcting it it still wont pass the tests

Thank you i really appreciate it, this my first time posting here.

Never mind i just wrote the text wrong, after some changes it passed the tests thanks for looking into it either way

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.