Tell us what’s happening:
Please tell me why not a single test passes except 1-4. Although everything works for me in the preview tab when I enter test lines by hand.
Your code so far
/* file: script.js */
const checkBtn = document.getElementById('check-btn');
const input = document.getElementById('text-input');
const result = document.getElementById('result');
let value = ''
input.addEventListener('input', (e) => {value = e.currentTarget.value})
const checkPalidrome = (str) => {
if (!str.length) {
alert('Please input a value')
} else {
const replacedStr = str.replace(/\W/g,'').replace(/_/g,'').toLowerCase()
const reversedStr = replacedStr.split('').reverse().join('')
if (replacedStr === reversedStr) {
result.innerHTML = str + ' is a palindrome'
} else {
result.innerHTML = str + ' is not a palindrome'
}
}
}
checkBtn.addEventListener('click', () => {checkPalidrome(value)})
Your browser information:
User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36 OPR/106.0.0.0
Challenge Information:
Build a Palindrome Checker Project - Build a Palindrome Checker