Tell us what’s happening:
Why is it not returning as false when it is not a palindrome? I have inserted the return false part outside the for and if statement.
Your code so far
function palindrome(str) {
// Good luck!
for(let i = 0; i<=str.length; i++) {
if(str[i].charAt(0) === str[i].charAt(str[i].length[i]-1)) {
str.toLowerCase().split(' ').join('');
return true;
}
}
return false;
}
palindrome("eye");
Your browser information:
User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/73.0.3683.86 Safari/537.36
.
Link to the challenge:
https://learn.freecodecamp.org/javascript-algorithms-and-data-structures/javascript-algorithms-and-data-structures-projects/palindrome-checker