Tell us what’s happening:
Hi there,
I’m a bit stuck on the missing letters algorithm. I can’t figure out why the first return statement is not exiting the function and loop. I also don’t understand why my answers for some tests, such as “abce”, are not being accepted even though they are correct.
Cheers!
Your code so far
function fearNotLetter(str) {
let alph = "abcdefghijklmnopqrstuvwxyz".split("");
let input = str.split("");
let i = alph.indexOf(str.charAt(0));
input.forEach(function(letter) {
if ( letter != alph[i] ) {
console.log(alph[i]);
return alph[i];
}
i++;
});
return undefined;
}
fearNotLetter("abcdefghjklmno");
Your browser information:
User Agent is: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_13_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/69.0.3497.100 Safari/537.36
.
Link to the challenge:
https://learn.freecodecamp.org/javascript-algorithms-and-data-structures/intermediate-algorithm-scripting/missing-letters