https://leetcode.com/problems/valid-palindrome/
Solution 1
/**
* @param {string} s
* @return {boolean}
*/
var isPalindrome = function (s) {
const lowerCaseString = s.toLowerCase();
let onlyLowerCase = '';
for (let i = 0; i < lowerCaseString.length; i++) {
const regex = /^[a-z0-9]/;
if (regex.test(lowerCaseString[i])) {
onlyLowerCase += lowerCaseString[i];
}
}
let reverseOnlyLowerCase = '';
for (let j = onlyLowerCase.length - 1; j >= 0; j--) {
reverseOnlyLowerCase += onlyLowerCase[j];
}
console.log(onlyLowerCase, reverseOnlyLowerCase);
return onlyLowerCase === reverseOnlyLowerCase;
};