Created
August 28, 2019 18:14
-
-
Save charuwts/e7e7e3a1895936800b50a64869fe9c63 to your computer and use it in GitHub Desktop.
Learning Code
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 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