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!

Hi! ,
I became with this solution,
Used 3 functions
first I made an array with codeStr with codes of each letter
second made a sampleCase whith codes (the case without missing letter)
then I filtered the sampleCase to any code not being in the codeStr, stored It as missing.
last I map the missing array back to letters, and join it with ‘’ (this way it brings back all the missing letters)

I really like your solution, can you explain to me a bit more?

It is great that you solved the challenge, but instead of posting your full working solution, it is best to stay focused on answering the original poster’s question(s) and help guide them with hints and suggestions to solve their own issues with the challenge.

We are trying to cut back on the number of spoiler solutions found on the forum and instead focus on helping other campers with their questions and definitely not posting full working solutions.

You’re right I edited the post.

function fearNotLetter(str) {

let alphabets = ‘abcdefghijklmnopqrstuvwxyz’;

for(let i = alphabets.indexOf(str[0]); i < alphabets.length; i++) {

    if(!str.includes(alphabets[i])) {

        return alphabets[i];

    }

}

}