Fool Palindromes

Fool Palindromes
0.0 0

#1

i’m little curious

what’s wrong here, if i want to solve like this way? please mention points and describe.

Your code so far

function palindrome(str) {
  // Good luck!
  var splitArray = str.split('');
  var reverseArray = splitArray.reverse();
  var joined = reverseArray.join('');
   
  if (joined == str) {
    return "true";
  }
  else {
    return "false";
  }
  return joined;
}

palindrome("eye");

Your browser information:

Your Browser User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/64.0.3282.186 Safari/537.36.

Link to the challenge:


#2

Several issues:

#1) Your function returns either “true” or “false”. These are string values instead of Boolean values of true or false. Ditch the quotation marks.

#2) You are ignoring the Note in the instructions. See below for the Note:

Note
You’ll need to remove all non-alphanumeric characters (punctuation, spaces and symbols) and turn everything lower case in order to check for palindromes.

#3) Although not technically an issue, the following line will never be executed, because the if/else statement forces the return of value before it could be executed. Since joined would not have been a true or false value, why did you even attempt to return it?

return joined;

#3

Thank you @randelldawson.
#1 & #2 is clear to me now but what have you meant @ #3?


#4

I have updated my original reply. I forgot to post the line to which I was referring. Sorry for the confusion.