Skip to content

Commit 57e8a30

Browse files
committed
added function
1 parent 5d99ac7 commit 57e8a30

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

Valid Palindrome/code.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
/*
2+
* @param {string} s
3+
* @return {boolean}
4+
*/
5+
const isPalindrome = s => {
6+
s = s.toLowerCase().replace(/[^a-z0-9]/gi,'');
7+
for (let i = 0, j = s.length - 1; i <= j; i++, j--) {
8+
if (s.charAt(i) !== s.charAt(j)) return false;
9+
}
10+
return true;
11+
}

0 commit comments

Comments
 (0)