Tell us what’s happening:
Every test case is passing except “1 eye for of 1 eye.”…I logged the array I created in console and the output was a palindrome yet the case keeps failing.
Your code so far
function palindrome(str) {
let newArr = str.replace(/[^a-zA-Z]+/g, "").toLowerCase().split('');
console.log(newArr);
for(let i = 0; i < newArr.length; i++){
if(newArr[i] !== newArr[newArr.length-i-1]) return false
}
return true;
}
palindrome("1 eye for of 1 eye.");
Your browser information:
User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/80.0.3987.122 Safari/537.36
.
Challenge: Palindrome Checker
Link to the challenge: