Palindrome Challenge

Palindrome Challenge


Help. I’ve since looked at the solutions to this challenge and feel competent with the necessary tools such as .replace and .toLowerCase, however I cannot for the life of me figure out why my original code won’t work! Any help is appreciated. The only test case it fails on is: "palindrome(“1 eye for of 1 eye.”)
it solves all of the other test cases correctly. Any help is appreciated. Thanks in advance!

function palindrome(str) {

var manipulative = str;
manipulative = manipulative.replace(/\W+/gi,’’);
manipulative = manipulative.replace(/\d+/gi,’’);
manipulative = manipulative.replace(/(_)/g,’’);
manipulative = manipulative.toLowerCase();
var forward = manipulative.split(’’);
var strForward = forward.join(’’);

var backward = forward.reverse();

var strBackward = backward.join(’’);

if (strBackward === strForward) {
return true;
else {
return false;



I think the problem is that you are removing digits, the algorithm states:

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


Simple, you removed all numeric characters and you shouldn’t have :wink:

You’ll need to remove all non-alphanumeric characters


but I did a test “return strBackward;” just to see and it was coming up with the right thing. at what point did I remove all the characters with that? is it that I wasn’t supposed to remove all the numbers? so take out the line:
manipulative = manipulative.replace(/\d+/gi,’’);


I’m not sure what you mean or how you tested that.

Yep, the challenge states you need to remove all non-alphanumeric characters, meaning all you have to keep is letters and numbers.

As \d in your regex matches digits, removing the line you mentioned should solve this.