Missing letters - Help Needed

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.


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] ) {
      return alph[i];
  return undefined;


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:

When you use a return statement in the callback function of for Each, you not exiting the fearNotLetter function. You are just causing the next iteration of the forEach to start. You should use a regular for loop here instead.

The only return statement that causes your function to exit is the last one, once the forEach has finished iterating over the input array. This means your fearNotletter function returns undefined for any call to it.

1 Like