Tell us what’s happening:
palindrome(“1 eye for of 1 eye.”) should return false.
why this input should return false?
According to the question this input should return true.
Your code so far
function palindrome(str) {
str = str.toLowerCase();
let regex = /[a-z]/g;
let result = [];
let flag = true;
for(let i=0;i<str.length;i++)
{
if(str[i].match(regex))
{
result.push(str[i]);
}
}
// console.log(result.join(""));
let len = result.length;
for(let i=0;i<len/2;i++)
{
console.log(result[i], result[len-1-i]);
if(result[i] !== result[len-1-i])
{
flag = false;
break;
}
}
return flag;
}
console.log(palindrome("almostomla"));
Your browser information:
User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/124.0.0.0 Safari/537.36
Challenge Information:
JavaScript Algorithms and Data Structures Projects - Palindrome Checker