Intermediate Algorithm Scripting: Missing letters

Hi there!

I have a slight problem with this challenge. When I test it in my IDE I get perfectly fine results, but fcc doesn’t accept it all. Maybe you can have a look if I miss something or I just have a total wrong approach.

Thanks a lot!

function fearNotLetter(str) {
const abc = ‘abcdefghijklmnopqrstuvwxyz’;
const abcArr = abc.split("");

for (let i = 0; i < abcArr.length; i++)
if (!str.includes(abcArr[i])) {
return abc[i]
return undefined;

Your browser information:

User Agent is: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/65.0.3325.162 Safari/537.36.

Link to the challenge:

The linter does not like the fact that you did not explicitly use { and } to surround your for loop’s code block.

Actually, even once you fix that, your function will fail the 3rd and 4th tests. It will also fail those tests in your IDE as you currently have it written.

I was going to say I think it’d fail too. If you are comfortable with regular expressions, you’ll have a much easier time imo.

I was just to redeem myself haha. My code expects the string to start from a!
Such a dumb mistake haha.
Thanks a lot anyway!

Yes. I just wanted to try something else. I just tested the first test and “undefined”.
I probably should go to bed haha.
Thanks mate!

If you think break will help, take it. Nothing is worse than looking at the screen with tired eyes.

Like the others, I’d expect your solution to not work either, as your approach makes some assumptions that aren’t always going to be the case.

I just attempted that challenge myself and the way I did it was basically by taking advantage of ASCII codes, as it’s generally easier to work with numbers than characters. Of course you can use RegEx too, as mentioned, but that’s generally sort of a quick-fix approach and probably not the approach that FCC wants you to take since RegExs don’t involve “algorithmic scripting”.

This is my solution, there are plenty of others that would work too:

function fearNotLetter(str) {
  let arr = str.split("");
  let ascii = => x.charCodeAt(0));
  for (let i = 1; i < ascii.length; i++) {
    if (ascii[i] > ascii[i-1] + 1) {
      return String.fromCharCode(ascii[i] - 1);

I rewrote my code and my solution was pretty similar. Actually straight forward and short!

function fearNotLetter(str) 
  let beginIndex = str.charAt(0).charCodeAt();

  for (let i=0; i < str.length; i++)
    let expected = String.fromCharCode(beginIndex + i); 
    if (expected !== str[i])
      return expected;

  return undefined;

@astv99, @R-Todorov Your code has been blurred out to avoid spoiling a full working solution for other campers who may not yet want to see a complete solution. In the future, please try to avoid posting full working solutions. Instead stick to giving suggestions and hints or examples similar, but not exact.

Thank you.

1 Like