i had completed my project code for a palindrome checker. after running tests its not completing the tests. i don’t know why this is happening.
please help me in this regard
here’s my code
const checkBtn = document.getElementById("check-btn")
const userInput = document.getElementById("text-input")
const result = document.getElementById("result")
const checkPalindrome = str => {
const ival = str;
if(str === "") {
alert("Please input a value");
return;
}
result.replaceChildren()
const lowerCaseStr = str.replace(/[^A-Za-z0-9]/gi, '').toLowerCase();
let resultMsg = `<strong>${ival}</strong> ${lowerCaseStr === [...lowerCaseStr].reverse().join('') ? 'is a ' : 'is not a '} Palindrome`;
result.innerHTML = resultMsg
}
checkBtn.addEventListener("click", ()=>{
checkPalindrome(userInput.value);
userInput.value = ''
} )
userInput.addEventListener('keydown' , e =>{
if(e.key === 'Enter'){
checkPalindrome(userInput.value)
userInput.value = ''
}
})