Help needed on Missing Letters

I’m solving Intermediate Algorithm scripting problems and I have to find the missing letter passed in the letter range and return them. If all letters are present, undefined must be returned.

`````` function fearNotLetter(str) {
var alph = "abcdefghijklmnopqrstuvwxyz";
var newstr;
for(var i = 0; i < alph.length; i++){
if(str[i] !== alph[i])
{
newstr = alph[i];
break;
}
}
return newstr;
}

fearNotLetter("abce");

``````

So far my code is working fine for the first two and last conditions. But it’s returning false/wrong for the middle two conditions. Kindly please help and point where I’m doing wrong.

what should you do if `str[0]` is not an `"a"`?

your function is returning `"a"` if that is the case

But I didn’t specifically define` str[0]` to be “`a`”. How does this work?

but alph[0] is always “a”, so when the check `str[0] !== arr[0]` is made and `str` starts somewhere else in the alphabet, this happen

look at the failing tests
`fearNotLetter("stvwx")`

in this case you have `str[0] !== alph[0]` being true because str[0] is “s”, and the function returns “a”

Can you tell me how to rectify this problem? Should I split “alph”?

consider this, if the string doesn’t always start from `a`, you can’t always check the alphabet from the `a` - there are a few ways to make this work, try thinking of a way

Can I use “Includes” method?

you could, but I honestly can’t think of a way how. if you have an idea, try!

I solved it this way.

`````` function fearNotLetter(str) {
var alph = "abcdefghijklmnopqrstuvwxyz";
var alph = alph.substr(alph.indexOf(str[0]), str.length);
var newstr;
for(var i = 0; i < alph.length; i++){
if(str[i] !== alph[i]){
newstr = alph[i];
break;
}
}
return newstr;
}

fearNotLetter("abce");
``````