Created
April 7, 2022 05:41
-
-
Save esase/31d2d3038118fcd74edc509408dac895 to your computer and use it in GitHub Desktop.
Valid palindrome [https://leetcode.com/problems/valid-palindrome]
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* @param {string} s | |
* @return {boolean} | |
*/ | |
var isPalindrome = function(s) { | |
s = s.replace(/[^a-z0-9/s]/gi, '').toLowerCase(); | |
return s.split('').reverse().join('') === s; | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment