Build a Palindrome Checker Project - Build a Palindrome Checker

idk know where is the problem is it in html or JavaScript, I’ve been trying to figure out this for so many days but couldn’t find the solution
I’m so frustrated.

pls help

<!-- file: index.html -->
<!DOCTYPE html>
<html lang="en">
<head>
   <link rel="stylesheet" href="styles.css">
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>palindrome checker</title>
</head>
<body>
  <script src="script.js"></script>
  <h1>freeCodeCamp</h1>
  <h2>Is it a Palindrome?</h2>
    <input id="text-input"></input>
<button id="check-btn">check</button>
<div id="result"></div>
</body>
</html>
/* file: script.js */
let textInput = document.getElementById
("text-input");
let checkButton = document.getElementById
("check-btn");
let result = document.getElementById
("result");

checkButton.addEventListener("click", palindrome);

function palindrome() {
if (textInput == "") {
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/127.0.0.0 Safari/537.36

Challenge Information:

Build a Palindrome Checker Project - Build a Palindrome Checker

Hello,
move this line <script src="script.js"></script> to the bottom of your html code just before the closing tag of the body element,
In JS code you are selecting the input element than comparing it to an empty string which does not make sense, to get the value of the input element, use the value property and finally replace the == by ===

1 Like

thank you very much, it worked

1 Like