Build a Missing Letter Detector - Build a Missing Letter Detector

Tell us what’s happening:

My code is doing what it is supposed to do, but I’m not passing. When I do the tests the answers are correct.

Your code so far

let az=('abcdefghijklmnopqrstuvwxyz')
let AZ=az.split('')

function fearNotLetter(text){

  let textSplit=text.split('');

  if (textSplit===AZ){
    return undefined
  }

  let compareText='';
  let wrongLetter=''
  for (let i=0;i<AZ.length;i++){
    if (AZ[i]===textSplit[0]){
      compareText=AZ.splice(i,textSplit.length)
    }
  }
  for (let i=0;i<textSplit.length;i++){
    if (textSplit[i]!==compareText[i]){
      wrongLetter=compareText[i]
      break;
    } 
  }
  return wrongLetter
}

console.log(fearNotLetter("abcdefghjklmno"))

Your browser information:

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

Challenge Information:

Build a Missing Letter Detector - Build a Missing Letter Detector

console.log(fearNotLetter("abce")); // the string d
console.log(fearNotLetter("abcdefghjklmno")); // the string i.
console.log(fearNotLetter("stvwx")); // the string u.
console.log(fearNotLetter("bcdf")); // the string e.
console.log(fearNotLetter("abcdefghijklmnopqrstuvwxyz")); // undefined.

What do you see in the console when you add this to the bottom of your code?

1 Like

Oh thanks, this helped. I forgot that the splice function mutates my AZ array.

Glad that helped. Please post your updated code if you need more help with this.

(post deleted by author)