DEV Community

Oscar Hernandez
Oscar Hernandez

Posted on

Missing letters FCC intermediate algorithm

//Intermediate Algorithm Scripting: Missing lettersPassed

//Find the missing letter in the passed letter range and return it.

//If all letters are present in the range, return undefined.//

function fearNotLetter(str) {
var args = []; var arr =[]; var arrX =[];
for(let i = 0; i < str.length; i++){
arr = str.charCodeAt(1+i);
if(arr > str.length){
args = String.fromCharCode(arr-1);
};
if(args[0] > str[i]){
arrX = args;
}else if(args[i] === str[i]){
arrX = undefined; console.log(arrX)
};
};

return arrX;
};
fearNotLetter("abce");
//fearNotLetter("abcdefghjklmno");
//fearNotLetter("stvwx");
//fearNotLetter("bcdf");
//fearNotLetter("abcdefghijklmnopqrstuvwxyz")
//https://www.freecodecamp.org/learn/javascript-algorithms-and-data-structures/intermediate-algorithm-scripting/missing-letters

Top comments (0)