Skip to content

Commit b51e6fe

Browse files
authored
Add isPalindrome function to check for palindromes
1 parent a460024 commit b51e6fe

1 file changed

Lines changed: 15 additions & 0 deletions

File tree

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
/**
2+
* @param {string} s
3+
* @return {boolean}
4+
*/
5+
var isPalindrome = function(s) {
6+
s = s.toLowerCase().replace(/[^a-z0-9]/g, "");
7+
8+
let m = "";
9+
10+
for (let i = s.length -1; i >= 0; i--){
11+
m += s[i];
12+
}
13+
14+
return s == m;
15+
};

0 commit comments

Comments
 (0)