/javascript-algorithms-and-data-structures/intermediate-algorithm-scripting/missing-letters

Tell us what’s happening:

hello guys i know what is going on but i cant really wrap my head around it if it dosent start at alphabets[i]
then it returns a
Your code so far


function fearNotLetter(str) {
var alphabets = "abcdefghijklmnopqrstuvwxyz";
alphabets = alphabets.split("");

str = str.split("");
 console.log(str)

for(var i = 0; i < str.length; i++){

  if(str[i] != alphabets[i]){
    return alphabets[i];
  }
  }

return alphabets;
}

console.log(fearNotLetter("stvwx"));

Your browser information:

User Agent is: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/79.0.3945.117 Safari/537.36.

Challenge: Missing letters

Link to the challenge:
https://www.freecodecamp.org/learn/javascript-algorithms-and-data-structures/intermediate-algorithm-scripting/missing-letters

is there something that tells you what’s the index of a particular character?

You’re close. How about if you get the indexOf position in that alphabet of the first character from the string passed into your function? Then, as you increment to the next character in the passed string, you also increment to the next index in the alphabet - if the characters don’t match, increment that alphabet index until they do and indicate somehow that there was a gap?

thank you i solved it :smiley:

1 Like