Skip to content

Commit 4a49e74

Browse files
committed
valid-palindrome solution
1 parent f56e213 commit 4a49e74

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

valid-palindrome/Jeehay28.js

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
/**
2+
* @param {string} s
3+
* @return {boolean}
4+
*/
5+
var isPalindrome = function (s) {
6+
const reg = /[a-z0-9]/g;
7+
const converted = s.toLowerCase().match(reg);
8+
9+
if (converted === null) {
10+
return true;
11+
} else {
12+
const forward = converted.join("");
13+
const backward = converted.reverse().join("");
14+
15+
return forward === backward;
16+
}
17+
};

0 commit comments

Comments
 (0)