I have tried running this code in JSFiddle and it’s working fine but when I try to Run the Tests it does not satisfy the requirements. Please help! Thank you!
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" />
<link rel="stylesheet" href="styles.css">
<title>Palindrome Checker</title>
</head>
<body>
<header>Palindrome Checker!</header>
<hr>
<p id="intro">Please type a word or phrase to check if they are palindromes!</p>
<input type="text" id="text-input" placeholder="Please type here..."><br>
<button type="button" id="check-btn">Check it!</button>
<p> Are you excited to see it?<br>Here it <strong>comes</strong>!</p>
<div id="result">
</div>
</body>
</html>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1" />
<link rel="stylesheet" href="styles.css">
<title>Palindrome Checker</title>
</head>
<body>
<header>Palindrome Checker!</header>
<hr>
<p id="intro">Please type a word or phrase to check if they are palindromes!</p>
<input type="text" id="text-input" placeholder="Please type here..."><br>
<button type="button" id="check-btn">Check it!</button>
<p> Are you excited to see it?<br>Here it <strong>comes</strong>!</p>
<div id="result">
</div>
</body>
</html>
const checkBtn = document.getElementById("check-btn")
const textArea = document.getElementById("text-input")
const results = document.getElementById("result")
checkBtn.addEventListener("click", () => {
const word = textArea.value
if (word === "") {
alert('"Please input a value"')
} else {
palindromeChecker()
}
})
function palindromeChecker(words) {
const word = textArea.value;
const reverseWord = word.replace(/[\s,|_()\\\/.: -]/g,"").split("").reverse().join("")
const trueWord = reverseWord.toLowerCase()
const realityWord = trueWord.split("").reverse().join("")
if (trueWord !== realityWord) {
result.innerHTML = word + " " + "is not a palindrome"
} else {
result.innerHTML = word + " " + "is a palindrome"
}
}