My solution so far for the missing letters challenge, working as expected with every test except the one with “stvwx” as the input (returning undefined instead of “u”), and I am stumped as to why. Can anyone explain what’s different about this test, and what’s missing from my code?
Thanks : )
Your code so far
function fearNotLetter(str) {
let alphabet = 'abcdefghijklmnopqrstuvwxyz';
let range = alphabet.slice(alphabet.indexOf(str[0]), str.length + 2);
for (var i = 0; i < range.length; i++) {
if (str.includes(range[i]) === false) {
return range[i];
}
}
return undefined;
}
console.log(fearNotLetter("abce"));
console.log(fearNotLetter("stvwx"));
Your browser information:
User Agent is: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/85.0.4183.102 Safari/537.36
.
Challenge: Missing letters
Link to the challenge: