Missing letters-what is wrong with my solution?

Does anyone know why this solution won’t pass the tests?

function fearNotLetter(str) {
  let alphabet = "abcdefghijklmnopqrstuvwxyz";

  let startingPoint = alphabet.indexOf(str[0]);
  let endingPoint = alphabet.indexOf(str[str.length - 1]);

  let strSub = alphabet.substring(startingPoint, endingPoint);
  let strSubSplit = strSub.split('');
  let strSplit = str.split('');
   
  let x = strSubSplit.map(function(e){
      return strSplit.indexOf(e) < 0;
      
  });
 return x.toString();
}

hi please post a link to the challenge you are trying to solve.

Usually when your solution is wrong the testcases will tell you which one failed and you can then try that testcase and see for yourself what output you get. (using console.log to determine how to move forward)

I’ve edited your code 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 (').


We can’t help without knowing more about what is wrong and what you’ve done so far.
What isn’t working as expected? What tests are failing? What specific behavior of piece of the code are you stuck on?

I assume you meant to use filter and not map. You will still not pass the last test but that is a simple fix as you can return undefined instead of an empty string.

console.log("" || undefined) // undefined

I am sorry. I am a little frustrated so I have not checked for a few days. Here is the link to the challenge Missing Letters:

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.