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.
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