A quicky using reduce in JS
First up it converts the array of letters to an array of char codes.
It then uses reduce to find the 2-code gap, and return the letter with char code one less that that of the letter just after the gap.
If there is more than one gap it will return the letter for the last one.
If there is no 2-code gap, then it will return undefined.
findMissingLetter = letters =>
.map(c => c.charCodeAt(0))
(acc, code, index, codes) => (index && code == codes[index - 1] + 2 ? String.fromCharCode(code - 1) : acc),
(checked on kata)
We're a place where coders share, stay up-to-date and grow their careers.
We strive for transparency and don't collect excess data.