Is Palindrome

Determine whether a string is a palindrome.

Contributed by @itsbrunodev

javascript
function isPalindrome(str) {
  const normalized = str.toLowerCase().replace(/[^a-z0-9]/g, "");
  return normalized === normalized.split("").reverse().join("");
}
javascript
isPalindrome("never odd or even"); // true
isPalindrome("race a car"); // false

Keywords

string
palindrome