# Check for palindromes

**URL:** <https://forum.freecodecamp.org/t/check-for-palindromes/75296>\
**Category:** General\
**Created:** [January 11, 2017, 5:28am UTC](https://forum.freecodecamp.org/t/check-for-palindromes/75296 "2017-01-11T05:28:05Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![johan2013](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/johan2013/32/34061_2.png) [@johan2013](https://forum.freecodecamp.org/u/johan2013)\
**Post date:** [January 11, 2017, 5:28am UTC](https://forum.freecodecamp.org/t/check-for-palindromes/75296/1 "2017-01-11T05:28:06Z")

</div>

Hi,  
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.

```javascript
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;
}

palindrome("eye");

```

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 repl.it and it works there  
Any ideas why?

---

<div class="post-metadata">

**Author:** ![kevcomedia](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/kevcomedia/32/125737_2.png) [@kevcomedia](https://forum.freecodecamp.org/u/kevcomedia)\
**Post date:** [January 11, 2017, 5:40am UTC](https://forum.freecodecamp.org/t/check-for-palindromes/75296/2 "2017-01-11T05:40:57Z")

</div>

I cleaned up your code.  
You need to use triple backticks to post code to the forum.  
See [this post for details](http://forum.freecodecamp.com/t/forum-code-formatting/25574).

Check your regex. You’re removing _everything that’s not a letter_.

---

<div class="post-metadata">

**Author:** ![johan2013](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/johan2013/32/34061_2.png) [@johan2013](https://forum.freecodecamp.org/u/johan2013)\
**Post date:** [January 11, 2017, 5:47am UTC](https://forum.freecodecamp.org/t/check-for-palindromes/75296/3 "2017-01-11T05:47:00Z")

</div>

Thanks.  
0-9 did the trick

---

<div class="post-metadata">

**Author:** ![ILM](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/ilm/32/363239_2.png) [@ILM](https://forum.freecodecamp.org/u/ILM)\
**Post date:** [January 16, 2021, 5:09pm UTC](https://forum.freecodecamp.org/t/check-for-palindromes/75296/4 "2021-01-16T17:09:36Z")

</div>

Closed on January 16, 2021, 5:09pm UTC


