hello everybody
i’m having more or less the same problems.
all the steps pass untill i put the code for the alphanumeric palindrome.
when i paste the code for alphanumeric palindrome
function isPalindrome(str) {
// Remove non-alphanumeric characters and convert to lowercase
str = str.replace(/[^0-9a-z]/gi, '').toLowerCase();
// Compare characters from the start and end of the string
// and stop if a mismatch is found or the middle of the string is reached.
for (let i = 0; i < str.length / 2; i++) {
if (str[i] !== str[str.length - i - 1]) {
return false;
}
}
return true;
}
// Prompt the user for input
checkButton.addEventListener('click', () => {
const inputText = inputField.value.trim();
if (inputField.value === '') {
resultDiv.textContent = 'enter some text';
return;
}
// Output the result
if (isPalindrome(inputText)) {
resultDiv.textContent = `"${inputText}" is a palindrome.`;
} else {
resultDiv.textContent = `"${inputText}" it is not a palindrome`;
}
});
any suggestions?