Hey everyone,
Im really trying to complete the Palindrome checker without just looking up answers and so far with putting some code together i have the below :
function palindrome(str) {
str.toLowerCase().replace(/[^a-zA-Z0-9]/g, '');
var splitstr = str.split()
var revstr = splitstr.reverse()
var joinstr = revstr.join(" ");
if (str === joinstr){
return true;
}
else return false;
}
console.log (palindrome("not"));
The problem is its not quite working. It seems to be accepting the true answers but not failing the false. Am i missing something obvious? or am i way off haha? Just hints would be appreciated as i would like to try and solve it as much on my own as possible.
Thanks everyone.
Luke