repl.it
@QuemuelVital/

Missing letters

Nodejs

Find the missing letter in the passed letter range and return it.

fork
loading
Files
  • index.js
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
  function fearNotLetter(str) {
  let letter;
  
  const ascii = a => a.charCodeAt(0);

  let ints = str.split('').map(ascii);
  
  ints.map((x) => { 
    if(ints.indexOf(x+1) === -1 && ints.indexOf(x) < ints.length - 1) {
      letter = x + 1;
    }
  });
  
  return typeof(letter) === 'number' ?  String.fromCharCode(letter) : undefined;
  
}

fearNotLetter("abce");