When I click check for the various words and phrases it works yet the boxes still dont get checked

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

function check() {
  if (textInput.value == "") {
    alert("Please input a value");
  } else if (palindrome(textInput.value)) {
    result.innerHTML = `${textInput.value} is a palindrome` 
  } else {result.innerHTML = `${textInput.value} is not a palindrome`}
  }

function palindrome(str) {
   const regex = /[^A-Za-z0-9]/g;
  var firstRegexStr = str.toLowerCase().replace(regex, '');
  var reverseStr = firstRegexStr.split('').reverse().join('');
  return reverseStr === firstRegexStr;
}



checkButton.addEventListener("click", check);

Please put your question in the body of your post. Also, please include a link to the Step. Thanks

I’ve edited your code for readability. 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 (').

Welcome to the forum @joeymorne

Please also post your html.

Happy coding

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