I write palindrome checker. It works for all the test case scenarios but "almostomla" and I don't know why.
My code:
function palindrome(str) {
//deleting all non-alphanumeric characters from the array and changing all the remaining characters to lowercases
str = str.replace(/[_W]+/g, "").toLowerCase();
const a = str.split('');
console.log(a);
const b = [...a].reverse().join('');
console.log(b);
const c = [...a].join('');
console.log(c);
for(var i=0; i<b.length; i++){
if(b[i] !== c[i]){
return false;
} else {
return true;
}
}
}
console.log(palindrome("almostomla"));