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, it fails:
- palindrome("_eye") should return true,
- palindrome(“race car”) should return true,
- palindrome(“A man, a plan, a canal. Panama”) should return true,
- palindrome(“never odd or even”) should return true,
- palindrome(“My age is 0, 0 si ega ym.”) should return true,
- 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”);