Last active
September 19, 2023 07:00
-
-
Save PatrickJS/5462522 to your computer and use it in GitHub Desktop.
Write a function that adds from two invocations in JavaScript
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 addf(x) { | |
return function(y) { | |
return x + y; | |
} | |
} | |
addf(3)(4) | |
------------------------- | |
function addf(x) { | |
var func = function(y) { | |
return x + y; | |
} | |
return func; | |
} | |
addf(3)(4) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
thanks for explanation! :)