Challenge Missing letters - Why is this code not working?

Challenge Missing letters - Why is this code not working?
0

#1

I can’t get why this code is wrong. I must be something obvious, I still can’t see it. Please give me hints so that I can solve this challenge :slight_smile:

function fearNotLetter(str) {
  
  for (var i = 1; i < str.length; i++) {
    if (str.charCodeAt(i) == str.charCodeAt(i-1)+1) {
      continue;
    } else {
      return str.fromCharCode(str.charCodeAt(i));
    }
  }
  return undefined;
}

#2

In your else statement, you should call fromCharCode differently :

String.fromCharCode(str.charCodeAt(i));

See the following information page : http://devdocs.io/javascript/global_objects/string/fromcharcode


#3

Thanks @Mizu. I corrected it into this:
return String.fromCharCode(str.charCodeAt(i));

However, I am still getting two red ticks. What else could be wrong? :slight_smile:


#4

Have you noticed that your return statement actually doesn’t return the missing letter ? What needs to be done ?


#5

Thanks again! I totally forgot it. I should add minus 1. :slight_smile:
It works now :smiley:


#6

Happy to help :slight_smile: Good coding!


#7

Thanks, to you too! All the best!