Tell us what’s happening:
my check button does not seem to be work. The code looks fine and I am not getting any error messages. I am not sure what to do as I am stuck on part 4 of this project.
Your code so far
<!-- file: index.html -->
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title></title>
</head>
<body>
<input id="text-input"></input>
<button id="check-btn">Check</button>
<div id="result"></div>
<script src="srcipt.js"></script>
</body>
</html>
/* file: script.js */
const textInput = document.getElementById("text-input");
const checkButton = document.getElementById("check-btn");
const result = document.getElementById("result");
checkButton.addEventListener("click", () => {
if (textInput.value === "") {
alert("please input a value")
}
else if (textInput.value.length === 1) {
result.innerText = `${textInput.value} is a palindrome`
}
else if (textInput.value === [...textInput.value].reverse().join("")) {
result.innerText = `${textInput.value} is a palindrome`
}
});
/* file: styles.css */
Your browser information:
User Agent is: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:137.0) Gecko/20100101 Firefox/137.0
Challenge Information:
Build a Palindrome Checker Project - Build a Palindrome Checker