Tell us what’s happening:
The program works as it is supposed to but does not pass the tests. for example, if i myself type in the test cases i get the desired results but when i Run the Tests it fails. Please assist
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.0">
<link rel="stylesheet" href="styles.css">
<title>Palindrome Checker</title>
</head>
<body>
<div id="main">
<h1>Palindrom Checker</h1>
<p id="instruction-text">Enter text to check if its a palindrom:</p>
<input type="text" id="text-input" class="text-input">
<button id="check-btn" class="check-btn">Check</button>
<p id="result" class="result"><i>''Result''</i></p>
<p id="info">A palindrome is a word or sentence that's spelled the same way both forward and backward, ignoring punctuation, case, and spacing.</p>
</div>
<script src="script.js">
</script>
</body>
</html>
/* file: styles.css */
body {
display: flex;
align-items: center;
justify-content: center;
background-color: 244855;
}
h1 {
font-family: Cambria;
text-align: center;
}
#main {
border: 1px solid black;
padding: 19px;
border-radius: 6px;
background-color: E64833;
width: 350px
}
#instruction-text {
font-family: Trebuchet MS;
text-align: center;
}
.text-input {
width: 100%;
height: 30px;
margin-bottom: 10px;
border-radius: 5px;
border: 1px;
font-family: Trebuchet MS;
}
.check-btn {
background-color: 244855;
border-radius: 7px;
width: 100%;
height: 30px;
color: white;
font-family: Trebuchet MS;
opacity: 0.7;
cursor: pointer;
/*pointer-events: none;*/
}
.check-btn.active {
opacity: 1;
pointer-events: auto;
}
.result {
background-color: white;
border-radius: 4px;
padding: 7px;
text-align: center;
font-family: Trebuchet MS;
}
#info {
font-family: Trebuchet MS;
text-align: center;
padding-top: 30px;
}
/* file: script.js */
const checkBtn = document.querySelector("#check-btn");
const inputText = document.querySelector("#text-input");
const resultText = document.querySelector("#result");
let filterInput;
checkBtn.addEventListener("click", () => {
if (inputText.value === "") {
alert("Please input a value");
return
}
else {
let reverseInput = filterInput.split("").reverse().join("");
if (reverseInput !== filterInput) {
resultText.innerText = `${inputText.value} is not a palindrome`;
return;
}
resultText.innerText = `${inputText.value} is a palindrome`;
}
});
inputText.addEventListener("keyup", () => {
filterInput = inputText.value.toLowerCase().replace(/[^A-Z0-9]/ig, "");
/*if(filterInput) {
return checkBtn.classList.add("active");
}
checkBtn.classList.remove("active");*/
});
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 Edg/127.0.0.0
Challenge Information:
Build a Palindrome Checker Project - Build a Palindrome Checker