Build a Palindrome Checker Project - Build a Palindrome Checker

Tell us what’s happening:

Been stuck for days on this step. I’ve looked on MDN, W3, everywhere. I can’t see what I’m doing wrong. Any help is appreciated.

Your code so far

<!-- file: index.html -->
<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="utf-8"/>
<script src="script.js"></script>
</head>

<body>
<input id="text-input" type="text" required />
<button id="check-btn"></button>
<div id="result"></div>
<script src="script.js"></script>
</body>
</html>
/* file: script.js */
const checkButton = document.getElementById("check-btn");
const textInput = document.getElementById("text-input");
checkButton.addEventListener("click", () => {
  if ("text-input" === "") {
  alert("Please input a value")}
  
});
/* file: styles.css */

Your browser information:

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

Challenge Information:

Build a Palindrome Checker Project - Build a Palindrome Checker

The condition in your if statement is wrong. This should refer to your variable name.

(“text-input” === “”)

Also the variable name on its own isn’t enough. The variable name just represents the element. You want to alert when no text has been inputted. You need to chain on something else.

I assume you are only querying the alert at this point?

I recommend checking your elements one more time and looking at the console.

1 Like