en.javascript.info/1-js/06-advanced-functions/06-function-object/5-sum-many-brackets/_js.view/source.js
Logan Schelly f20fb43f70 Add test case/sandbox for 1-js/06-advanced-functions/06-function-object/5-sum-many-brackets
I used the solution and examples already in the article.
I chose to make the test cases use Array.reduce() to compute the sum,
instead of hard-coding the answer myself.
Not sure how good of practice that is.
2020-06-10 15:29:06 -06:00

13 lines
182 B
JavaScript

function sum(a){
// Your code goes here.
}
/*
sum(1)(2) == 3; // 1 + 2
sum(1)(2)(3) == 6; // 1 + 2 + 3
sum(5)(-1)(2) == 6
sum(6)(-1)(-2)(-3) == 0
sum(0)(1)(2)(3)(4)(5) == 15
*/