Skip to content

Instantly share code, notes, and snippets.

@smashingpat
Created August 25, 2017 08:10
Show Gist options
  • Save smashingpat/02f23f3c021b56d0160e8d02a077839f to your computer and use it in GitHub Desktop.
Save smashingpat/02f23f3c021b56d0160e8d02a077839f to your computer and use it in GitHub Desktop.
JS Bin // source https://jsbin.com/fibiri
<!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>
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