Created
October 8, 2019 23:23
-
-
Save MarvinJWendt/0916f2615f3542627b6f719f8f2f0c8e to your computer and use it in GitHub Desktop.
Chaining JavaScript Functions
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
const log = console.log | |
const is = (x) => { | |
return { | |
plus: (plus) => { | |
return is(x + plus) | |
}, | |
ten: () => { | |
return (x === 10) | |
}, | |
minus: (minus) => { | |
return is(x - minus) | |
} | |
} | |
} | |
log(is(5).plus(5).ten()) | |
log(is(5).plus(5).plus(1).ten()) | |
log(is(10).ten()) | |
log(is(11).minus(1).ten()) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment