Tell us what’s happening:
I have checked and rechecked this overe and over with AI and I cannot tell what is wrong please help!
Your code so far
<!-- file: index.html -->
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Palindrome Checker</title>
<link rel="stylesheet" href="styles.css" type="text/css">
<script src="script.js" defer></script>
</head>
<body>
<div class="container">
<input id="text-input" type="text" placeholder="Enter text here">
<button id="check-btn">Check Palindrome</button>
<p id="result"></p>
</div>
</body>
</html>
/* file: script.js */
document.getElementById("check-btn").addEventListener("click", () => {
const inputText = document.getElementById("text-input").value.trim();
const resultElement = document.getElementById("result");
if (inputText === "") {
resultElement.textContent = "Please input a value";
return;
}
const cleanInput = inputText.replace(/[^a-zA-Z0-9]/g, "").toLowerCase();
const isPalindrome = cleanInput === cleanInput.split("").reverse().join("");
if (isPalindrome) {
resultElement.textContent = `"${inputText}" is a palindrome`;
} else {
resultElement.textContent = `"${inputText}" is not a palindrome`;
}
});
document.getElementById("text-input").addEventListener("input", () => {
const inputTextValue = document.getElementById("text-input").value.trim();
const checkBtn = document.getElementById("check-btn");
checkBtn.disabled = inputTextValue === "";
});
/* file: styles.css */
*{margin:0;
padding:0;
box-sizing:border-box;
background-color:green;
}
.container{
width:100%;
min-height:100vh;
position:relative;
display:flex;
align-items:flex-end;
justify-content:flex-start;
}
Your browser information:
User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/134.0.0.0 Safari/537.36 Edg/134.0.0.0
Challenge Information:
Build a Palindrome Checker Project - Build a Palindrome Checker