Created
May 24, 2017 03:32
-
-
Save cosmicbuffalo/7a653d38c35e30ce7f4877ddbb0ffb43 to your computer and use it in GitHub Desktop.
Instructor David's arrow function for binary string expansion algorithm
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
const binaryStringExpansion = (str) => ( | |
(str.indexOf('_') === -1) ? | |
[str] : | |
binaryStringExpansion(str.replace('_', '0')) | |
.concat( | |
binaryStringExpansion(str.replace('_', '1')) | |
) | |
); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This is an algorithm my instructor David at Coding Dojo showed me, and this was my first exposure to arrow functions.