Created
March 30, 2016 13:57
-
-
Save jasonbellamy/5887656609c906c6413cf383efff800e to your computer and use it in GitHub Desktop.
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 functionFactory({ type, ...rest }) { | |
switch(type) { | |
case 'hi': | |
return hello(rest); | |
case 'bye': | |
return goodbye(rest); | |
} | |
}; | |
function hello({ name }) { | |
return `Hello ${name}`; | |
} | |
function goodbye({ name }) { | |
return `Goodbye ${name}`; | |
} | |
// functionFactory({ type: 'hi', name: 'Dave' }) // Hello Dave | |
// functionFactory({ type: 'bye', name: 'Dave' }) // Goodbye Dave |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment