This is where you can share your code for solving the Palindrome Checker exercise ![]()
I’ve seen these trip people up when they forget to handle case sensitivity or spaces. Just checking toLowerCase() and stripping non-alphanumeric characters usually sorts it out. Otherwise, it’s a pretty straightforward comparison.
function isPalindrome(str) {
const cleanedStr = str.toLowerCase().replace(/[^a-z0-9]/g, '');
const reversedStr = cleanedStr.split('').reverse().join('');
return cleanedStr === reversedStr;
}
Nice one — cleaning the string first is the part most people skip, and it’s exactly what makes this work on something like ‘A man, a plan, a canal: Panama’. Lowercasing plus stripping out the non-alphanumerics, then comparing against the reversed string, is about as clean as this one gets.