Build a Palindrome Checker Project - Build a Palindrome Checker

Tell us what’s happening:

Maybe I’ve just been staring at this too long, but I don’t understand why this wont pass.

Your code so far

<!-- file: index.html -->
<input id='text-input'></input>
<button id='check-btn'></button>
<div id='result'></div>
/* file: styles.css */

/* file: script.js */
const input = document.getElementById("text-input");
const button = document.getElementById("check-btn");
const result = document.getElementById("result")
const str = input.value.replace(/[\W_]/g, "");
const lowerd =  str.toLowerCase()
const rev = lowerd.split("").reverse().join("")

const checkForPalindrome = () => {
   if(lowerd === rev){ 
    result.innerText=`${input.value} is a palindrome`
    }else{
    result.innerText=`${input.value} is not a palindrome`
    }
};

button.addEventListener("click", checkForPalindrome);

Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:129.0) Gecko/20100101 Firefox/129.0

Challenge Information:

Build a Palindrome Checker Project - Build a Palindrome Checker

When you click on the #check-btn element without entering a value into the #text-input element, an alert should appear with the text "Please input a value".

I don’t see any code for an alert.

Which test are you talking about?

none of the tests seem to run with my current code. I have added the following code to send an alert, but this portion doesn’t seem to want to run either. There is an error somewhere in my code and I cannot seem to find it.

if(input === “”) {
alert(“Please input a value”)
}

What kind of troubleshooting did you do?

Try putting in a console.log() at different points in the code to see if your function gets triggered or other events.