Intermediate Algorithm Scripting: Missing letters-help

Ok I really tried my best to solve this algorithm . This is my code so far. What am I doing wrong.

function fearNotLetter(str) {
  let letter = "abcdefghijklmnopqrstuvwxyz";
  let lettersArr = letter.split("").sort((a, b) => a - b);
   for(let i = 0; i < lettersArr; i++) {

     return str.indexOf(lettersArr[i]) === -1 ? lettersArr[i].join(''):undefined;


Intermediate Algorithm Scripting: Missing letters

1 Like

Your for loop only makes one iteration, because you return a value in the first pass. Once a return statement is executed, the function immediately exits and does not come back to finish a loop.

Even after you address the return issue, all you’re doing is seeing if each letter in str exists in lettersArr, which will always return true. That’s not completely what you want.