Please help me with this code, it doesn’t want to run
Your code so far
<!-- file: index.html -->
<!DOCTYPE html>
<html>
<head>
<title>Palindrome Checker</title>
<style>
body {
text-align: center;
font-family: Arial, sans-serif;
}
h1 {
margin-top: 20px;
}
#text-input {
margin-top: 20px;
padding: 5px;
font-size: 16px;
}
#check-btn {
margin-top: 10px;
padding: 10px 20px;
background-color: #4CAF50; /* Green */
color: white;
font-size: 16px;
border: none;
}
#result {
margin-top: 20px;
font-size: 18px;
}
</style>
</head>
<body>
<h1>Palindrome Checker</h1>
<input type="text" id="text-input" placeholder="Enter a word or phrase">
<button id="check-btn">Check</button>
<div id="result"></div>
<script>
function isPalindrome(word) {
var reverseWord = word.split('').reverse().join('');
return word.toLowerCase() === reverseWord.toLowerCase();
}
document.getElementById('check-btn').addEventListener('click', function() {
var input = document.getElementById('text-input').value.trim();
if (input === '') {
alert('Please input a value');
} else if (isPalindrome(input)) {
document.getElementById('result').textContent = input + ' is a palindrome';
} else {
document.getElementById('result').textContent = input + ' is not a palindrome';
}
});
</script>
</body>
</html>
/* file: styles.css */
/* file: script.js */
Your browser information:
User Agent is: Mozilla/5.0 (Linux; Android 10; K) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/122.0.0.0 Mobile Safari/537.36
Challenge Information:
Build a Palindrome Checker Project - Build a Palindrome Checker