Missing Letters challenge Question

I just completed the Missing Letters challenge from JavaScript Algorithms and Data Structures. Although my solution passed, I felt badly that it had only worked for the first missing letter when I tested it for multiple missing letters. When I tested the solutions, which included higher level functions like CharCodeAt() that mine didn’t, I discovered that none of the solutions worked with multiple missing letters, either. I felt better until I started trying unsuccessfully to change my code to make it work for multiple missing letters. Can anyone here demonstrate how that could be done?

If you want to share your solution, we can help you build on it.

Thank you for the response. This is the first time I’ve tried posting/asking a question here, so I hope putting it here like this is okay.

function fearNotLetter(str) {
  var alphabet = 'abcdefghijklmnopqrstuvwxyz';
  var l = str.length;
  var s = alphabet.indexOf(str[0]);
  
  for(var i = s; i < s+ l; i++){
    if(!str.includes(alphabet[i])){
      return alphabet[i];

  }
  return undefined;
}

I blurred your code with spoiler tags and added some formatting.


I’ve edited your post for readability. When you enter a code block into a forum post, please precede it with a separate line of three backticks and follow it with a separate line of three backticks to make it easier to read.

You can also use the “preformatted text” tool in the editor (</>) to add backticks around text.

See this post to find the backtick on your keyboard.
Note: Backticks (`) are not single quotes (’).

Ok. So without worrying about writing the code yet, what are some changes that you’ll need to make to achieve your new goal?

What type of data do you want to return? An array? A string? An object?
Where do you need your return statement to be?
Can you anticipate any problems you might encounter after you have found a first missing letter and continue to look for more?

Think about the logical solution to the problem before you try translating that logic into code changes. Feel free to keep bouncing ideas off of us here or sharing your code if you try something and get stuck.

Thank you for telling me about the backticks!