Created
August 15, 2021 13:05
-
-
Save samandar-boymurodov/908e45d7c0202ed555cb4f15d52dfaad 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 sum (n) { | |
if (n === undefined) return 0 | |
let inc = n | |
function add (k) { | |
if (k === undefined) return inc | |
inc += k | |
return add | |
} | |
return add | |
} | |
console.log(sum(1)(2)(3)()) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment