Build a Missing Letter Detector - Build a Missing Letter Detector

Tell us what’s happening:

I don’t understand how I could’ve passed all the other tests, except only for tests 3 and 4. What is wrong with my code that makes it so that only those two tests couldn’t pass?

Your code so far

function fearNotLetter(str) {
  let allLetters = "abcdefghijklmnopqrstuvwxyz";
  let allSplit = allLetters.split("");
  let strSplit = str.split("");
  let lastIndex = allSplit.indexOf(strSplit[0]) + strSplit.length;
  let match = allSplit.slice(allSplit.indexOf(strSplit[0]), lastIndex);
  let missing = "";

  for (let i = 0; i < strSplit.length; i++) {
    if (str == allLetters) {
      missing = undefined;
    } else if (match[i] !== strSplit[i]) {
      missing = match[i];
    }
  }

  return missing;

}


console.log(fearNotLetter("stvwx"));

Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/145.0.0.0 Safari/537.36

Challenge Information:

Build a Missing Letter Detector - Build a Missing Letter Detector

look at what happens to each variable line by line using a tool like this: https://pythontutor.com/

put your function and a function call and observe line by line what happens

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.