Palindrome Checker (FreeCodeCamp)

PHOTO EMBED

Tue Aug 04 2020 19:25:25 GMT+0000 (Coordinated Universal Time)

Saved by @ludaley #javascript #strings #arrays

function palindrome(str) {
    const alphanumericOnly = str
        // 1) Lowercase the input
        .toLowerCase()
        // 2) Strip out non-alphanumeric characters
        .match(/[a-z0-9]/g);
        
    // 3) return string === reversedString
    return alphanumericOnly.join('') ===
        alphanumericOnly.reverse().join('');
}



palindrome("eye");

content_copyCOPY

https://www.freecodecamp.org/news/freecodecamp-palindrome-checker-walkthrough/