Last active
May 5, 2020 12:24
-
-
Save zaetrik/8ef328086f8271f59367f9039306dc3b to your computer and use it in GitHub Desktop.
Function Composition
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 composition is the process of building more complex functions from simpler ones | |
const add = (x: number, y: number) => x + y | |
const say = (x: number) => `Your number is ${x}` | |
// Let's compose our two functions to build something more complex | |
const sayAddResult = (x: number, y: number) => say(add(x, y)) | |
sayAddResult(2, 5) // Your number is 7 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment