Created
November 12, 2019 22:22
-
-
Save stephane777/c5e2af774acc026a986babb8a8fdc7fb to your computer and use it in GitHub Desktop.
This file contains hidden or 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 add (x, y) { | |
| return x + y | |
| } | |
| function makeAdder (x, addReference) { | |
| return function (y) { | |
| return addReference(x, y) | |
| } | |
| } | |
| const addFive = makeAdder(5, add) | |
| const addTen = makeAdder(10, add) | |
| const addTwenty = makeAdder(20, add) | |
| addFive(10) // 15 | |
| addTen(10) // 20 | |
| addTwenty(10) // 30 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment