Created
August 14, 2015 16:13
-
-
Save alexandrebvd/0e781f8469f5b97a8f0b to your computer and use it in GitHub Desktop.
25.Bonfire: Missing letters
This file contains 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 missing = ''; | |
var isMissing = false; | |
for (var i = 0; i < str.length-1; i++) { | |
if (str.charCodeAt(i+1) - str.charCodeAt(i) !== 1 && !isMissing) { | |
missing = String.fromCharCode(str.charCodeAt(i)+1); | |
isMissing = true; | |
} else if (!isMissing) { | |
missing = undefined; | |
} | |
console.log(missing); | |
} | |
return missing; | |
} | |
fearNotLetter('bcd'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment