Last active
February 28, 2016 12:24
-
-
Save sedera-tax/b66ab0b3a4ee23fb2a79 to your computer and use it in GitHub Desktop.
Missing letters. Find the missing letter in the passed letter range and return it. If all letters are present in the range, return undefined.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function fearNotLetter(str) { | |
var x = 0; | |
var res = 0; | |
for (var i=0; i<str.length; i++) { | |
var y = str.charCodeAt(i); | |
if(x !== 0){ | |
if(y !== x+1){ | |
res = x + 1; | |
break; | |
} | |
} | |
x = y; | |
} | |
if(res !== 0){ | |
str = String.fromCharCode(res); | |
} | |
else{ | |
str = undefined; | |
} | |
return str; | |
} | |
fearNotLetter("abce"); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment