I made an array of the string, and translated it into one of Unicode codes. A loop start value matches the lowest code value of the string and continues until the last code number. Every letter code could be compared to the loop variable with a stop and return of the first letter code that is not available named as the loop variable it could be. Strings with codes matching loop variables would return undefined.
The while loop marks the beginning of issues. Though this is a finite array I chose a for loop to practice using them. Nothing is produced. I am not sure where to place return undefined so that a loop can be made through the whole array.
function fearNotLetter(str) {
let array = str.split("");
let coded = array.map(letter => letter.charCodeAt());
let start = Math.min(...coded);
let i = start;
let missingMember = 0;
while (i < coded.length) {
console.log(coded[i]);
if (coded[i] === i) {
i++;
}
return undefined;
}
missingMember = coded[i];
return missingMember;
}
fearNotLetter("abce");
**Your browser information:**
User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/88.0.4324.150 Safari/537.36 Edg/88.0.705.63
.
Challenge: Missing letters
Link to the challenge: