Skip to content

Instantly share code, notes, and snippets.

@junojo
Forked from tomanistor/problem.md
Created September 4, 2021 08:38
Show Gist options
  • Select an option

  • Save junojo/d0a30b5fc8bb80220b50656986cdcdf6 to your computer and use it in GitHub Desktop.

Select an option

Save junojo/d0a30b5fc8bb80220b50656986cdcdf6 to your computer and use it in GitHub Desktop.

Revisions

  1. @tomanistor 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);
    }
    }
    }