The requirements for this task are that the code is returns a 'true' or 'false' for an input string. The string can be a simply word or a phrase. The other question does not address these needs. Please reopen and answer here. I am working on a function to check if a given string is a palindrome. My code seems to work for simple one-word palindromes but not for palindromes that feature capitalization or spaces.
function palindrome(str)
{
var palin = str.split("").reverse().join("");
if (palin === str){
return true;
} else {
return false;
}
}
palindrome("eye");//Succeeds
palindrome("Race car");//Fails