# Check for Palindromes algorithm challenge

**URL:** <https://forum.freecodecamp.org/t/check-for-palindromes-algorithm-challenge/133698>\
**Category:** General\
**Created:** [July 3, 2017, 7:04am UTC](https://forum.freecodecamp.org/t/check-for-palindromes-algorithm-challenge/133698 "2017-07-03T07:04:20Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![hermiyantoeko](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/hermiyantoeko/32/58558_2.png) [@hermiyantoeko](https://forum.freecodecamp.org/u/hermiyantoeko)\
**Post date:** [July 3, 2017, 7:04am UTC](https://forum.freecodecamp.org/t/check-for-palindromes-algorithm-challenge/133698/1 "2017-07-03T07:04:20Z")

</div>

Good afternoon,

I am currently doing Check for Palindromes. I have checked my code independently, and the code can be run very well. But, when I use the code in [https://www.freecodecamp.org/challenges/check-for-palindromes](https://www.freecodecamp.org/challenges/check-for-palindromes), it fails:

1. palindrome("\_eye") should return true,
2. palindrome(“race car”) should return true,
3. palindrome(“A man, a plan, a canal. Panama”) should return true,
4. palindrome(“never odd or even”) should return true,
5. palindrome(“My age is 0, 0 si ega ym.”) should return true,
6. palindrome(“0\_0 (: /-\ 🙂 0-0”) should return true.

But, when I checked independently, the code did not fail on these tests.

* * *

function revStrFunc(str) {  
var myNameArray = str.split(’’);  
var myNameArrayB = [‘a’, ‘b’];  
for (i = 0; i \< str.length; i++) {  
myNameArrayB[i] = myNameArray.pop();  
}  
return myNameArrayB.join(’’);  
}

function charStripFunc(str) {  
var strippedChars = str.replace(/[^A-Za-z0-9]/g,’’);  
return strippedChars.toLowerCase();  
}

function palindrome(str) {  
var strippedChars = charStripFunc(str);  
var reversedStr = revStrFunc(strippedChars);  
if(str === reversedStr) {  
return true;  
} else {  
return false;  
}  
}

palindrome(“0\_0 (: /-\ 🙂 0-0”);

---

<div class="post-metadata">

**Author:** ![JohnnyBizzel](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/johnnybizzel/32/37661_2.png) [@JohnnyBizzel](https://forum.freecodecamp.org/u/JohnnyBizzel)\
**Post date:** [July 3, 2017, 7:21am UTC](https://forum.freecodecamp.org/t/check-for-palindromes-algorithm-challenge/133698/2 "2017-07-03T07:21:57Z")

</div>

> [@hermiyantoeko](#):
>
> function revStrFunc(str) {  
> var myNameArray = str.split(‘’);  
> var myNameArrayB = [‘a’, ‘b’];  
> for (i = 0; i \< str.length; i++) {  
> myNameArrayB[i] = myNameArray.pop();  
> }  
> return myNameArrayB.join(‘’);  
> }
> 
> function charStripFunc(str) {  
> var strippedChars = str.replace(/[^A-Za-z0-9]/g,‘’);  
> return strippedChars.toLowerCase();  
> }
> 
> function palindrome(str) {  
> var strippedChars = charStripFunc(str);  
> var reversedStr = revStrFunc(strippedChars);  
> if(str === reversedStr) {  
> return true;  
> } else {  
> return false;  
> }  
> }

What does this do? `if(str === reversedStr) {`

---

<div class="post-metadata">

**Author:** ![hermiyantoeko](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/hermiyantoeko/32/58558_2.png) [@hermiyantoeko](https://forum.freecodecamp.org/u/hermiyantoeko)\
**Post date:** [July 3, 2017, 9:39am UTC](https://forum.freecodecamp.org/t/check-for-palindromes-algorithm-challenge/133698/3 "2017-07-03T09:39:20Z")

</div>

Thank you very much for your enlightenment. It helps me so much. Now I understand my mistake. Previously, I debug the code inside Firefox Scratchpad and console by using console.log(strippedChars) and console.log(reversedStr) while commenting the if else which returning true and false.

Thank you again and I am sorry for my ignorance.

---

<div class="post-metadata">

**Author:** ![JohnnyBizzel](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/johnnybizzel/32/37661_2.png) [@JohnnyBizzel](https://forum.freecodecamp.org/u/JohnnyBizzel)\
**Post date:** [July 3, 2017, 9:40am UTC](https://forum.freecodecamp.org/t/check-for-palindromes-algorithm-challenge/133698/4 "2017-07-03T09:40:59Z")

</div>

Try using [Pythontutor](http://pythontutor.com/) for debugging.

No need to apologise for ignorance. We are learning all the time.

---

<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 17, 2021, 8:48pm UTC](https://forum.freecodecamp.org/t/check-for-palindromes-algorithm-challenge/133698/5 "2021-01-17T20:48:58Z")

</div>

Closed on January 17, 2021, 8:48pm UTC


