Intermediate Algorithm Scripting:: Missing letters

Tell us what’s happening:

Your code so far


function fearNotLetter(str) {
  var alph="";
  var str1="";
  for(var i=97;i<123;i++){
    alph+=String.fromCharCode(i);
}
var x=alph.indexOf(str[0]);
var y=alph.indexOf(str[str.length-1]);
for(var j=x;j<=y;j++){
  return str1+=alph[j];
}
var str3=str.concat(str1);
let myReg=new RegExp(str1+".*");
if(myReg.test(str1)===false){
  return undefined;
}
else{
    console.log(str3.filter(item => {!str1.includes(item) || !str.includes(item)}));
}

}
fearNotLetter("abce");

I never used hint from the curriculum,while solving when problem occurs i used to search in internet for the some methods,
Can anybody tell me where i went wrong.

Your browser information:

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

Challenge: Missing letters

Link to the challenge:

  1. You are returning in the second for loop, that will break you out of the loop and function.

  2. I don’t think the Regex is doing what you want (technically you can just hardcode a check for str === alph although that isn’t really the right option).

  3. str3 is not an array, it is a string.

  4. You are not returning anything from the filter callback, if you want to use an implicit return you have to remove the braces {}. You will also need to join the array so you return a string and not an array.

1 Like

ok,got it thank you :slightly_smiling_face: