Looking for a way to find multiple missing letters in an array? Check out this code snippet:
function missingLetters(str) {
var nums = str.split('').map(function(letter){
return letter.charCodeAt();
})
var result = [];
for(var i=0; i<nums.length - 1; i++){
if(nums[i+1] - nums[i] >1){
for(var j = nums[i]+1 ; j< nums[i+1]; j++){
result.push(String.fromCharCode(j));
}
}
}
return result;
}
missingLetters("abceghj");
This revised code will loop through every element in the array and return an array of all missing letters between existing ones.