Created
December 5, 2020 17:41
-
-
Save canattofilipe/3430ed1936d58fb29eb097d113a09597 to your computer and use it in GitHub Desktop.
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
function execute(fn, ...params) { | |
return function (text) { | |
return `${text} ${fn(...params)}`; | |
}; | |
} | |
function sum(a, b, c) { | |
return a + b + c; | |
} | |
function multiply(a, b) { | |
return a * b; | |
} | |
const r1 = execute(sum, 4, 5, 7)("The sum result is"); | |
const r2 = execute(multiply, 5, 2)("The multiply result is"); | |
console.log(r1); | |
console.log(r2); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment