Tell us what’s happening:
The system says
palindrome(“1 eye for of 1 eye.”) should return false
But as far as my debugging,
(“1 eye for of 1 eye.”) === to lower case alphabet only ==> (eyeforofeye)
e == e
y == y
e == e
f == f
o == o
and the middle is ‘r’.
so I can’t see any flaw in my code and i think it should be true.
Please spot me if there is any logical error in my implementation
Your code so far
function palindrome(str) {
str=str.split(/\W*\d*[_]*/).join('').toLowerCase()
console.log(str)
console.log(str.length,str.length/2 >>0)
for(var i=0;i<str.length/2 >>0;i++){
if(str[i]!=str[str.length-i-1]){
console.log('i , ',str[i], 'length-i-1',str[str.length-i-1])
return false
}
}
return true;
}
palindrome("1 eye for of 1 eye.")
Your browser information:
User Agent is: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/86.0.4240.75 Safari/537.36
.
Challenge: Palindrome Checker
Link to the challenge: