Tell us what’s happening:
The test palindrome(“1 eye for of 1 eye.”) is failing as its returning true while its expected to be false. Although it seems that ‘eyeforofeye’ is palindrome and my code is returning the both str and reversed as same .
Your code so far
function palindrome(str) {
let alphaStr = str.replace(/[^a-z]/ig,"").toLowerCase();
let rvrsdalphaStr = ""
let lenofstr = alphaStr.length - 1
for (let i = lenofstr ; i >= 0 ; i--) {
rvrsdalphaStr += alphaStr[i] ;
}
return alphaStr === rvrsdalphaStr
}
console.log(palindrome("1 eye for of 1 eye."));
palindrome("1 eye for of 1 eye.") should return false
Your browser information:
User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:85.0) Gecko/20100101 Firefox/85.0
.
Challenge: Palindrome Checker
Link to the challenge: