Tell us what’s happening:
Hi, I think I am close to solve this challenge but am stuck. I checked the advance solutions but want to know if it is possible to solve it without using regular expression but by using something similar to my code below.
(Excuse me for my repetitive code. I am in progress to write neat one.)
Thank you so much in advance.
Your code so far
function fearNotLetter(str) {
const complete = "abcdefghijklmnopqrstuvwxyz".split("");
const start = str[0];
const end = str[str.length-1];
const startingIndex = complete.findIndex((ele) => ele === start);
const endIndex = complete.findIndex((ele)=> ele === end);
const pickingAlphabets = complete.splice(startingIndex,endIndex+1 );
let result;
for(let j=0;j< str.length; j++){
if(pickingAlphabets[j]!== str[j]){
return result = pickingAlphabets[j];
} else if(pickingAlphabets[j]=== str[j]){
return result = undefined
}
return result; //I am not sure what to return...
}
}
fearNotLetter("abce");
Your browser information:
User Agent is: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/107.0.0.0 Safari/537.36
Challenge: Intermediate Algorithm Scripting - Missing letters
Link to the challenge: