Skip to content

Instantly share code, notes, and snippets.

@charuwts
Created August 28, 2019 18:14
Show Gist options
  • Save charuwts/e7e7e3a1895936800b50a64869fe9c63 to your computer and use it in GitHub Desktop.
Save charuwts/e7e7e3a1895936800b50a64869fe9c63 to your computer and use it in GitHub Desktop.
Learning Code
// function within function
const createMultiplierShortHand = y => x => x * y;
// In other words
const createMultiplier = (y) => {
return (x) => {
return x * y;
};
};
const double = createMultiplier(2);
const triple = createMultiplier(3);
console.log(double); // [Function]
console.log(double(2)); // 4
console.log(triple(2)); // 6
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment