Palindrome Checker : Frontend Coding Exercise

This is where you can share your code for solving the Palindrome Checker exercise :slight_smile:

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;
}