Intermediate Algorithm Scripting - Missing letters

Tell us what’s happening:
Describe your issue in detail here.

Hello, please help me to figure out why its not passing the test, even though its resulting in desire output.

Your code so far

function fearNotLetter(str) {
  let alphaKey;
  let alpha = ['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'];
  
  str = str.split('');
  let i =0;
  while(i < alpha.length){
    if(str[0]===alpha[i]){
      alphaKey = i;
    }
    i++
  }

  let y =0;
  for(let x= alphaKey; x<alpha.length; x++){
    
    if(alpha.length == str.length){
     str = 'undefined';
     break;
    
    }
    else if(str[y]==alpha[x]){
      y++;
    } else if(str[y]!=alpha[x] && y<str.length) {
      str = alpha[x];
      break;
    }
    else {
      str = 'undefined';
      break;
    }
  }

  return str;
}

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

Your browser information:

User Agent is: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/114.0.0.0 Safari/537.36

Challenge: Intermediate Algorithm Scripting - Missing letters

Link to the challenge:

It should return the primitive value undefined, not the string “undefined”.

1 Like

thanks @bbsmooth. I understood now.

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