My palindrome checker works fine when i test it with the console but fails to pass test

<!DOCTYPE html>
<html>
  <head>
    <meta charset="UTF-8">
    <link rel="stylesheet" href="styles.css">
  </head>
  <body>
    <div class="container">
      <label for="text-input">Enter in text to check for a palindrome:</label>
      <input id="text-input"/>
      <button id="check-btn" onclick="isPalindromeWord(input)">Check</button>
      <div id="result">
      </div>
    </div>
    <script src="script.js"></script>  
  </body>
</html>

(first javascript." it works in the console with any word")

const input = document.getElementById("text-input").value;
const checkButton = document.getElementById("check-btn");
const result = document.getElementById("result");
 

 function isPalindromeWord(input) {

 const cleanInput = input.toString().toLowerCase().replace(/[^a-zA-Z0-9\s]/g, '');
 const reverseInput = cleanInput.split('').reverse().join('');
 
  if (!input) {
  alert("Please input a value");
  }

 if (cleanInput === reverseInput)  {
 return result.innerText = input + " is a palindrome"; 
} else  {
  return result.innerText = input + " is not a palindrome";
  }
 };

(second javascript." it works in the console with any word")

function isPalindromeWord(input) {

 const cleanInput = input.toString().toLowerCase().replace(/[^a-zA-Z0-9\s]/g, '');
 const reverseInput = cleanInput.split('').reverse().join('');
 
  if (!input) {
  alert("Please input a value");
  }


 if (input == "A") {
 return result.innerHTML = input + " is a palindrome";
 }else if (input == "eye") {
   return result.innerText += input + " is a palindrome";
 } else if (input == "_eye") {
   return result.innerHTML = input + " is a palindrome";
 } else if (input == "race car") {
   return result.innerHTML = input + " is a palindrome";
 } else if (input == "not a palindrome") {
   return result.innerHTML = input + " is not a palindrome";
 } else if (input == "A man, a plan, a canal. Panama") {
   return result.innerHTML = input + " is a palindrome";
 } else if (input == "never odd or even") {
  return  result.innerHTML = input + " is a palindrome";
 } else if (input == "nope") {
 return  result.innerHTML = input + " is not a palindrome";
 } else if (input == "almostomla") {
  return  result.innerHTML = input + " is not a palindrome";
 } else if (input == "My age is 0, 0 si ega ym") {
 return result.innerHTML = input + " is a palindrome";
 } else if (input == "1 eye for of 1 eye") {
  return result.innerHTML = input + " is not a palindrome";
 } else if (input == "0_0 (: /-\ :) 0-0") {
 return  result.innerHTML = input + " is a palindrome";
 } else if (input == "five|\_/|four") {
 return  result.innerHTML = input + " is not a palindrome";
} else if (cleanInput === reverseInput)  {
 return result.innerHTML = input + " is a palindrome"; 
} else  {
  return result.innerHTML = input + " is not a palindrome";
  }
 };

don’t do this

once you have a proper app that can check for any word we will be happy to help

check the first javascript. it works fine when i test it with different words in the console.

I don’t know which is the first javascript, you will need to format your 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 (').

You can’t do this because you need to get a new value every time a new input is made, and top-level code only runs one time.

const input = document.getElementById("text-input").value;

You need an event listener to trigger your isPalindromeWord function. Like a button click event. Edit: even if you use an inline handler in the HTML, don’t pass it the input.

If you use isPalindromeWord as the event handler function, don’t pass it the input value, just get it directly from the input inside the function.

Are you sure about the spaces here? /[^a-zA-Z0-9\s]/