Skip to content

Instantly share code, notes, and snippets.

@cosmicbuffalo
Created May 24, 2017 03:32
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cosmicbuffalo/7a653d38c35e30ce7f4877ddbb0ffb43 to your computer and use it in GitHub Desktop.
Save cosmicbuffalo/7a653d38c35e30ce7f4877ddbb0ffb43 to your computer and use it in GitHub Desktop.
Instructor David's arrow function for binary string expansion algorithm
const binaryStringExpansion = (str) => (
(str.indexOf('_') === -1) ?
[str] :
binaryStringExpansion(str.replace('_', '0'))
.concat(
binaryStringExpansion(str.replace('_', '1'))
)
);
@cosmicbuffalo
Copy link
Author

This is an algorithm my instructor David at Coding Dojo showed me, and this was my first exposure to arrow functions.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment