Hi all,
So this isn’t so much problem help, more refining help. I can’t help but feel that the solution I created is the long way around of doing things. It works fine, but I don’t have much experience outside of freeCodeCamp and I wanted to ask for help refining this code. Thanks for any help in advance!
Cayne
Your code so far
// Good luck!
var eStr = []; //edited string
var rStr = []; //reversed string
var lStr = ""; //lowercase string
var crap = ["_"," ",":","/","\\",":","-",",",".","\(","\)"];
lStr = str.toLowerCase();
for (i = 0; i < crap.length; i++) {
var reg = new RegExp("\\" + crap[i],"g");
lStr = lStr.replace(reg, "");
}
eStr = lStr.split('');
rStr = eStr;
rStr.reverse();
eStr = lStr.split('');
for (i = 0; i < eStr.length; i++) {
if (eStr[i] === rStr[i]) {
} else {
return false;
}
}
return true;
}
palindrome("eye");
Your browser information:
Your Browser User Agent is: Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/64.0.3282.119 Safari/537.36
.
Link to the challenge:
https://www.freecodecamp.org/challenges/check-for-palindromes