Finds the missing letter in the passed letter range and returns it. If all letters are present in the range, returns undefined.
A script by V.
function missingLetters(str) { | |
var seq = "abcdefghijklmnopqrstuvwxyz"; | |
var firstEntry = seq.indexOf(str[0]); | |
var missing = ""; | |
var missingCounter = 0; | |
var j = 1; | |
for (var i=firstEntry+1;i<firstEntry+str.length;i++){ | |
if (str.charCodeAt(j) != seq.charCodeAt(i+missingCounter)){ | |
missing = missing.concat(seq[i+missingCounter]); | |
missingCounter = missingCounter+1; | |
} | |
j = j+1; | |
} | |
if (missing === ""){ | |
missing = undefined; | |
} | |
return missing; | |
} | |
missingLetters("bcd"); |