DEV Community

Discussion on: Building a Palindrome Checker using Split, Join and replace methods

Collapse
 
erellsworth profile image
Edward Ellsworth

You could simplify the return statement like this:

function isPalindrome(str) {
    const palindrome = str.replace(/[^0-9a-z]/gi, '').toLowerCase();

    return palindrome.split('').reverse().join('') === palindrome;
}
Collapse
 
amarachijohnson profile image
Amarachi Johnson-Ubah

Oh! Thanks. This is a lot more simplified and brief