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`;
}
});
do you think the problem is only the word for word match?
I mean , is the code correct?
why without that last bit of code, all the steps pass the test and dont pass with that piece of code?
that is one of the thinks I
dont understand…
i removed the quotes " ----"
changed some words and passed all the steps.
// Output the result
if (isPalindrome(inputText)) {
resultDiv.textContent = `${inputText} is a palindrome.`;
} else {
resultDiv.textContent = `${inputText} is not a palindrome`;
}
});