Created
September 17, 2020 16:44
-
-
Save YouCanKeepSilence/a13612200aee32c8fad03067a612a136 to your computer and use it in GitHub Desktop.
Interview task sum (curry-like)
This file contains hidden or 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
/** | |
Напишите функцию sum которая умеет складывать числа. Пример работы: | |
sum(1); // => console: 1 | |
sum(1)(2)(3); // => console: 1 3 6 | |
*/ | |
function sum(number) { | |
let counter = number; | |
console.log(counter); | |
return function a(number1) { | |
counter += number1; | |
console.log(counter); | |
return a; | |
} | |
} | |
sum(1)(2)(3)(5) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
JSBin solution here