I solved this exercise quickly, but I am confident this wasn’t the fastest or cleanest way to do it. Could anyone offer any advice or material to read? I have very little experience in coding - but for these algorithm challenges I feel like playing the game “Human Resource Machine” has educated me more than some of the articles on Mozilla that are linked. I am reading through “Learn JavaScript and jQuery” by Duckett and “JavaScript: The Good Parts” by Crockford.
function palindrome(str) {
var noSpace = str.replace(/\s+/gi, "");
var noCaps = noSpace.toLowerCase();
var outString = noCaps.replace(/[`~!@#$%^&*()_|+\-=?;:'",.<>\{\}\[\]\\\/]/gi, "");
var array = [];
array = outString.split("");
array.reverse();
var joinedA = "";
joinedA = array.join("");
if (outString == joinedA){
return true;
} else {
return false;
}
}
palindrome("eye");