Tell us what’s happening:
I have completed the test, but when referring to other ways, I have encountered a code that makes me difficult to understand.
Your code so far
// Adding this solution for the sake of avoiding using 'for' and 'while' loops.
// See the explanation for reference as to why. It's worth the effort.
function fearNotLetter(str) {
var compare = str.charCodeAt(0), missing;
str.split('').map(function(letter,index) {
if (str.charCodeAt(index) == compare) {
++compare;
} else {
missing = String.fromCharCode(compare);
}
});
return missing;
}
// test here
fearNotLetter("abce");
So, what is the function of “missing” in the following case:
var compare = str.charCodeAt(0), missing;
What is the difference when declaring variables in this way?
Link to the challenge:
https://learn.freecodecamp.org/javascript-algorithms-and-data-structures/intermediate-algorithm-scripting/missing-letters