Tell us what’s happening:
my code is ok still showing error dont know why its running when running through vs code
Your code so far
<!-- file: index.html -->
<input id='text-input'>
<button id='check-btn'>check</button>
<div id='result'></div>
/* file: script.js */
const button = document.querySelector("#check-btn");
const result = document.querySelector("#result");
function removeNonAlphanumeric(str) {
return str.replace(/[^a-zA-Z0-9]/g, '');
}
button.addEventListener("click", () => {
let input = document.getElementById("text-input").value.trim().toLowerCase();
let modified_input = removeNonAlphanumeric(document.getElementById("text-input").value.trim().toLowerCase())
let reversed_input = removeNonAlphanumeric(input.split('').reverse().join(''))
if (!input) {
alert("Please input a value");
}else if(modified_input === reversed_input){
result.innerText = `${input} is a palindrome`
}else{
result.innerText = `${input} is not a palindrome`
}
});
/* file: styles.css */
Your browser information:
User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/131.0.0.0 Safari/537.36
Challenge Information:
Build a Palindrome Checker Project - Build a Palindrome Checker