Tell us what’s happening:
Describe your issue in detail here.
Hello fellows Campers ,
I am currently doing the Palindrome Checker exercise. I wrote the code below, and it passes most of the check tests. But there are 3 of them that don’t return the good result. I can’t really know how and why, I’ve been searching for a solution but I can’t figure it out. Maybe one of you could tell me what is the problem ?
Thank you for your help !
**Your code so far**
function palindrome(str) {
const nonAlpha = /^[^a-zA-Z0-9]+$/;
str.replace(nonAlpha, "");
const lowerCaseString = str.toLowerCase();
let strMaxIndex = str.length - 1;
let startIndex = 0;
while (startIndex !== strMaxIndex) {
if (lowerCaseString[startIndex] === lowerCaseString[strMaxIndex]) {
startIndex += 1;
strMaxIndex -= 1;
return true // console.log(str + " is a palindrome !");
} else if (lowerCaseString.length <= 2) {
return false // console.log(str + " can't be a palindrome");
} else {
return false // console.log(str + " is not a palindrome :(");
}
}
}
palindrome("eye");
**Your browser information:**
User Agent is: Chrome/103.0.0.0 Safari/537.36
Challenge: Palindrome Checker
Link to the challenge: