Skip to content

Instantly share code, notes, and snippets.

@tomanistor
Created June 22, 2017 17:40
Show Gist options
  • Save tomanistor/b10a36cafdb024927c82b3d10ade04a1 to your computer and use it in GitHub Desktop.
Save tomanistor/b10a36cafdb024927c82b3d10ade04a1 to your computer and use it in GitHub Desktop.

Revisions

  1. tomanistor created this gist Jun 22, 2017.
    19 changes: 19 additions & 0 deletions problem.md
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,19 @@
    ### Find the missing letter

    Write a method that takes an array of consecutive (increasing) letters as input and that returns the missing letter in the array.

    You will always get an valid array. And it will be always exactly one letter be missing. The length of the array will always be at least 2.
    The array will always contain letters in only one case.

    Example:

    ```
    ['a','b','c','d','f'] -> 'e'
    ['O','Q','R','S'] -> 'P'
    ```

    (Use the English alphabet with 26 letters!)

    Have fun coding it and please don't forget to vote and rank this kata! :-)

    I have also created other katas. Take a look if you enjoyed this kata!
    8 changes: 8 additions & 0 deletions solution.js
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,8 @@
    function findMissingLetter(array) {
    var string = array.join("");
    for (var i = 0; i < string.length; i++) {
    if (string.charCodeAt(i + 1) - string.charCodeAt(i) != 1) {
    return String.fromCharCode(string.charCodeAt(i) + 1);
    }
    }
    }