Missing letters, should work but how return undefined>>?

Tell us what’s happening:

my solution succeeds at nearly all checkmarks, but fails the undefined check.

As far as I can see from other forums and descriptions, mine should be returning undefined…??

Your code so far


function fearNotLetter(str) {
  let letters = 'abcdefghijklmnoprstuvwxyz';
  let start = letters.indexOf(str[0]);
  for (let i = 0; i < str.length; i++) {
    if (str[i] != letters[i+start]){
      return letters[i+start];
    }
  }
  
}


console.log(fearNotLetter("abcdefghijklmnoprstuvwxyz"));

Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/75.0.3770.100 Safari/537.36.

Link to the challenge:
https://learn.freecodecamp.org/javascript-algorithms-and-data-structures/intermediate-algorithm-scripting/missing-letters

Your solution would pass the last test if your letters variable had all of the letters of the alphabet.

1 Like