@lionel-rowe, I finished that challenge before ever creating this post. FYI, this was the code I submitted that worked:
function palindrome(str) {
var cleanStr = str.toLowerCase();
var array = cleanStr.split("");
array = array.filter(function(val){
return (val >= "a" && val <= "z") || val === 0 || (val > 0 && val <= 9);
// this didn't remove spaces: return (val >= "a" && val <= "z") || (val >= 0 && val <= 0);
});
// this is corrected, per @alper6: return (val >= "a" && val <= "z") || (val >= "0" && val <= "9");
});
cleanStr = array.join("");
var reverseArray = array.reverse();
var reverseStr = reverseArray.join("");
if (cleanStr === reverseStr) {
return true;
}
else {
return false;
}
} </spoiler>
What does it take to get those spoiler tags to work???
But you introduced something I haven’t seen before. What is codePointAt() - what does it do?
@alper6, I agree, my solution is fine for the task as given. But in the hint explanation, they point out that it’s much too inefficient if the “string” you’re checking is the Bible. And their algorithm is just much, much better: to compare characters starting at the front and back of the string. Once two characters don’t match, you know it’s not a palindrome and don’t need to check the rest of the string, so it’s much faster.
@Emgo-Dev, I’ve already explored a multitude of sources (have to be free for now) on JS. They all deal with the syntax and console-style problems, which sure, I need to improve on. What I specifically want is a JS source that teaches how to get inputs from a web page form, use them in functions and provide output or next steps. If I have multiple inputs in a form, each one needs its own listener, yet I need to wait for all of the inputs in order to take the next action… this should be so basic, because it’s such a common thing, but no one seems to have instruction or exercises/projects for it.
Been through Codecademy - I know the basics, just need practice (which I’m getting from FCC, but again still at console level).
I’ll take a look at MDN, which I find overly complicated, but I hadn’t found the place your link leads to. Thanks!