We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent aa151cd commit 32a4a18Copy full SHA for 32a4a18
valid-palindrome/lhc0506.js
@@ -0,0 +1,15 @@
1
+/**
2
+ * @param {string} s
3
+ * @return {boolean}
4
+ */
5
+var isPalindrome = function(s) {
6
+ const filteredLowercaseChars = [...s.toLowerCase()].filter(char => (char.charCodeAt() >= 97 && char.charCodeAt() <= 122) || (char.charCodeAt() >= 48 && char.charCodeAt() <= 57));
7
+
8
+ const filteredLowercaseCharsLength = filteredLowercaseChars.length;
9
10
+ for (let i = 0; i < filteredLowercaseCharsLength / 2; i++) {
11
+ if (filteredLowercaseChars[i] !== filteredLowercaseChars[filteredLowercaseCharsLength - 1 - i]) return false;
12
+ }
13
14
+ return true;
15
+};
0 commit comments