Skip to content

Instantly share code, notes, and snippets.

@jasonbellamy
Created March 30, 2016 13:57
Show Gist options
  • Save jasonbellamy/5887656609c906c6413cf383efff800e to your computer and use it in GitHub Desktop.
Save jasonbellamy/5887656609c906c6413cf383efff800e to your computer and use it in GitHub Desktop.
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