Check for palindromes

Check for palindromes


I’m stuck and do not know why. I suppose you have heard this before.
Here is my loooong solution, did it this way to get my head around it.

function palindrome(str) {
var removeSpecialChar = str.replace(/[^A-Za-z]/g, "");  //the caret shows what is allowed
var lowCase = removeSpecialChar.toLowerCase(); //long ways to follow the logic for bugs
var splitChar = lowCase.split('');
var revChar = splitChar.reverse();
var joinIt = revChar.join('');

  return joinIt === lowCase;


It works on all 12 other tests, except for one sentence

palindrome("1 eye for of 1 eye.") should return false.

I test it on and it works there
Any ideas why?


I cleaned up your code.
You need to use triple backticks to post code to the forum.
See this post for details.

Check your regex. You’re removing everything that’s not a letter.


0-9 did the trick