Missing Letters - missing test case? (SPOILER)

Here’s the link to the algorithm page:
https://learn.freecodecamp.org/javascript-algorithms-and-data-structures/intermediate-algorithm-scripting/missing-letters

I noticed that the test cases for this algorithm don’t cover a certain scenario: What if the string passed to the function is a substring of the alphabet (i.e. less than 26 characters long) but includes all characters of that substring in order? For example, here’s a test case I came up with:

fearNotLetter("bcdef") // should return "undefined".

Despite the above not being accounted for in the official exercise tests, my solution passed as follows:

function fearNotLetter(str) {
  const ALPHABET = "abcdefghijklmnopqrstuvwxyz";
  if (str === ALPHABET) {
    return undefined;
  }
  let startingPoint = ALPHABET.indexOf(str[0]);
  for (let i = 0; i < str.length; i++) {
    if (str[i] !== ALPHABET[startingPoint + i]) {
      return ALPHABET[startingPoint + i];
    }
  }
  // return undefined;
}

That commented-out “return undefined” was the line I added in afterwards, to cover cases such as the example test case I included above – but the code passes without it.

Is this an oversight in the exercise? Or is it supposed to be this way?

If it is indeed an oversight, I’d like to make a pull request to suggest adding one more test case to this algorithm – but I wanted to ask here first, to make sure I wasn’t misunderstanding anything.

Thank you for helping make FCC better. Bugs can be reported as GitHub Issues. Whenever reporting a bug, please check first that there isn’t already an issue for it and provide as much detail as possible.

1 Like

Okay, I just reported it. Thanks for the tip, Ariel!