Need help on the "missing letters" challenge

Hey(french here, bad english hazard ,you’ve been warned),
i know that this code is pretty rudimentay/clunky and clearly not the prettiest.
i know that i can use other methods and i’ll gladly do so when i understand why my ugly code is broken when these function calls are made :
fearNotLetter(“stvwx”);
fearNotLetter(“bcdf”);
for the other calls my code’s working just fine.

if any savior has the answer please make my hours of research end and lemme go to the next challenge :frowning:

  **Your code so far**

function fearNotLetter(str) {
const alphabet = ["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 workBench= str.split(""); //make str an array 
var start = alphabet.indexOf(workBench[0]); //find where we need to start slicing alphabet to have a pecise range of comparisson

var comparissonRange = alphabet.slice(start,workBench.length+1);// we now have the sample of the alphabet that will help us detect the missing letter
   
var verdict= comparissonRange.map(x=> !workBench.includes(x));//will return an array(verdict) of booleans false, if we can find the letter in both arrays and true if the letter is missing
    console.log(alphabet[(verdict.indexOf(true))])
return alphabet[(verdict.indexOf(true))]; //we can now return the letter missing based on its index

}

fearNotLetter("abce");
  **Your browser information:**

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

Challenge: Missing letters

Link to the challenge:

Do you understand the difference between the tests that are passing and the tests that are not? All the tests that are passing have something in common that the failing tests do not. For me, that is a big clue on where to look. Then I would put in console.log statements in different parts of the function to figure out what is going wrong.

1 Like

your magic is powerfull, just passed the challenge the issue was a lack of perspective.
thanks :slight_smile: :grinning:

2 Likes

“What’s different” is one of my favorite debugging questions.

1 Like