# Missing Letter Algorithm help

Missing Letter Algorithm help
0

#1

Missing Letters Algorithm Challenge
I have written out the below function for the above challenge. My code works only when the given parameter starts with ‘a’. However, when the parameter starts with another letter (eg. efghjkl) I cannot get it to return the missing letter ‘i’ in this case. I’ve tried to write some ‘if’ statements, but none of them worked, so I just took them out below. Any help to get this code to work when str[0] != ‘a’ would be appreciated. I’m guessing the if statement will have to change the index, but I’m not sure how to do that. Thank you

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

for(var i=0; i<str.length; i++){
if(str[i] != alphabet[i]){
return alphabet[i];
}
}
}

fearNotLetter("abcdefgijk");
``````

#2

Take a look at this function and see if it helps you.

#3

And also, letters a-Z are within the ASCII key, so you might wanna google “ASCII table as well”.

#4

because this line will always evaluate to false. For example, test case

`fearNotLetter("bcdf")` won’t work because you right from the start, you are comparing letter “b” with the first value in the array which is “a” and so forth…

What I would do to solve this challenge is use something like charcodeat and fromcharcode string methods ton convert your strings into asciicodes and try to find missing values.

#5

Documentation which was conveniently posted right before you did.

#6

I am not an expert, just completed same challenge after some time myself. But think about where you starting your loop, and maybe you could start at that exact letter str begins with. Maybe add extra variable at the top to represent that using some of array methods on your alphabet variable. i completed it with very similar structure as you trying to there. Ps you could also short your code a bit with by putting split on same line as alphabet, it works, as:
var alphabet = “abcdefghijklmnopqrstuvwxyz”.split("");

Liltle hint:
Think of indexOf method and also how could you maybe use starting position var minus looping index, to get to right letter. as: indexOf(str[i - starter]).