Skip to content

Commit a6f2dd8

Browse files
author
mykoo
committed
valid-palindrome
1 parent 1c502dd commit a6f2dd8

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

valid-palindrome/GUMUNYEONG.js

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

0 commit comments

Comments
 (0)