isPalindrome with JavaScript


  • 0
    N
    /**
     * @param {string} s
     * @return {boolean}
     */
    var isPalindrome = function(s) {
        let input = s.replace(/(\W)/g, '');   
        
        return (input) ? input.toLowerCase() === input.toLowerCase().split('').reverse().join('') : true;
    };
    

Log in to reply
 

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.