Missing Letters Challenge Feedback

The following is my solution. It works, but I was wondering if I could get some feedback. Good or bad, please let me know. Thank you so much in advance!

function fearNotLetter(str) {

var alphArray = [“a”, “b”, “c”, “d”, “e”, “f”, “g”, “h”, “i”, “j”, “k”, “l”, “m”, “n”, “o”, “p”, “q”, “r”, “s”, “t”, “u”, “v”, “w”, “x”, “y”, “z”];

var myArray = str.split("");
var i = 0;

while (myArray[i] === alphArray[i]) {
i++;
}

if (i > 0) {
return alphArray[i];
}
else return undefined;

}

fearNotLetter(“abce”);

Quick note, the forum can format your code by surrounding it with triple back-ticks

``` ```

The back tick (grave accent) moves around depending on which keyboard you use, so check this StackOverflow post to find it.

As for your code, I think it’s a nice implementation. Obviously, it works, and there aren’t going to be any major performance hangups. There’s nothing wrong with it, but I would encourage you to try the challenge again using the methods linked to in the problem, String.prototype.charCodeAt() and String.fromCharCode(). Doing this will teach you valuable skills for matching letters and processing strings. Even if you end up with an uglier, slower algorithm, it will be worth the effort. Otherwise, great job!

1 Like

Thank you very much for the insight! :smiley: