Palindrome help

Palindrome help
0

#1

hey all,

Any help here would be appreciated, not sure what is off here…

function palindrome(str) {
var cleanstring=str.replace(/[\W_]/g,'').toLowerCase();
var splitreverse=cleanstring.split('').reverse();
  var joined=splitreverse.join('');
  
  if (splitreverse==joined){
    return true;
  }
 else {
   return false;
 } 
}




palindrome("eye");

#2

your splitreverse is an array and your joined is a string. do some console logs and you will find out what is wrong


#3

Really helpful, thank you.


#4

Actually you were also comparing the new string with the new string.

`function palindrome(str) {
var cleanstring = str.replace(/[\W_]/g,’’).toLowerCase();
var newString = cleanstring.split(’’).reverse().join(’’);

if (cleanstring == newString){
return true;
}
else {
return false;
}
}

The general idea and the regExp was correct.Just some minor issues all and all :smiley:
Pasted the code as you were really close so don’t feel like you are cheating or something.