function isPalindrome(s) {
const charArray = Array.from(s.replace(/[^a-zA-Z0-9]/gim,'').toLowerCase());
const reverseCharArray = Array.from(charArray);
reverseCharArray.reverse();
if ( charArray == reverseCharArray ) {
return true;
} else {
return false;
}
};
let s = "A man, a plan, a canal: Panama"
console.log(isPalindrome(s))
I've tried == too ,but still get the same result.
Is there a better way to tackle this problem? Thank you in advance ;)!
Do I have to create a for loop and check if each index of the array is the same value?