Created
August 25, 2017 08:10
-
-
Save smashingpat/02f23f3c021b56d0160e8d02a077839f to your computer and use it in GitHub Desktop.
JS Bin // source https://jsbin.com/fibiri
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
<!DOCTYPE html> | |
<html> | |
<head> | |
<meta charset="utf-8"> | |
<meta name="viewport" content="width=device-width"> | |
<title>JS Bin</title> | |
</head> | |
<body> | |
<script id="jsbin-javascript"> | |
const compose = (funcs) => | |
funcs | |
.reduce((a, b) => (...args) => a(b(...args))); | |
const double = num => num * 2; | |
const increment = num => num + 1; | |
const incrementThenDouble = compose([ | |
double, | |
increment, | |
]); | |
const result = incrementThenDouble(2); | |
console.log(result); | |
</script> | |
<script id="jsbin-source-javascript" type="text/javascript">const compose = (funcs) => | |
funcs | |
.reduce((a, b) => (...args) => a(b(...args))); | |
const double = num => num * 2; | |
const increment = num => num + 1; | |
const incrementThenDouble = compose([ | |
double, | |
increment, | |
]); | |
const result = incrementThenDouble(2); | |
console.log(result); | |
</script></body> | |
</html> |
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
const compose = (funcs) => | |
funcs | |
.reduce((a, b) => (...args) => a(b(...args))); | |
const double = num => num * 2; | |
const increment = num => num + 1; | |
const incrementThenDouble = compose([ | |
double, | |
increment, | |
]); | |
const result = incrementThenDouble(2); | |
console.log(result); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment