Created
November 28, 2015 19:37
-
-
Save codebubb/f0e1c4ac6be1e6592919 to your computer and use it in GitHub Desktop.
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
| // Bonfire: Missing letters | |
| // Author: @codebubb | |
| // Challenge: http://www.freecodecamp.com/challenges/bonfire-missing-letters?solution=function%20fearNotLetter(str)%20%7B%0A%20str%20%3D%20str.split(%27%27).map(function(c%2C%20i)%7B%0A%20%20%20%20%20%20return%20(c.charCodeAt()%20!%3D%20str.charCodeAt()%20%2B%20i)%20%3F%20String.fromCharCode(str.charCodeAt()%2Bi)%20%3A%20%27undefined%27%3B%0A%20%7D)%3B%0A%20return%20str.lastIndexOf(%27undefined%27)%20%3F%20str%5Bstr.lastIndexOf(%27undefined%27)%2B1%5D%20%3A%20%27undefined%27%3B%0A%20%09%0A%7D | |
| // Learn to Code at Free Code Camp (www.freecodecamp.com) | |
| function fearNotLetter(str) { | |
| str = str.split('').map(function(c, i){ | |
| return (c.charCodeAt() != str.charCodeAt() + i) ? String.fromCharCode(str.charCodeAt()+i) : 'undefined'; | |
| }); | |
| return str.lastIndexOf('undefined') ? str[str.lastIndexOf('undefined')+1] : 'undefined'; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment