Skip to content

Instantly share code, notes, and snippets.

@pokorson
Created August 23, 2017 10:25
Show Gist options
  • Save pokorson/c352ceb9888bffdc71554869519596b9 to your computer and use it in GitHub Desktop.
Save pokorson/c352ceb9888bffdc71554869519596b9 to your computer and use it in GitHub Desktop.
currying
const greet = (greeting, name) => {
console.log(`${greeting} ${name}`);
};
greet("hello", "Adam");
greet("hello", "Mateusz");
greet("hi", "Mateusz");
greet("hi", "Adam");
const createGreeting = greeting => {
return name => {
console.log(`${greeting} ${name}`);
};
};
const hiGreeting = createGreeting("hi");
const helloGreeting = createGreeting("hello");
hiGreeting("Adam");
hiGreeting("Mateusz");
helloGreeting("Mateusz");
helloGreeting("Adam");
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment