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;
   }
}

fearNotLetter("abce");

Intermediate Algorithm Scripting: Missing letters

1 Like

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.