Help on basic algorithm section

Help on basic algorithm section


Hi. What am I doing wrong here?

This code returns palindromes as true…but not non-palindromes as false.


function palindrome(str) {
if (str === str.split().reverse().join()) {
return true;
return false;



So close!
Your split() and join() methods are missing separators.
Use split("") and join("") and it will work. You want to separate each individual letter and then join again.