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.
13 lines
182 B
JavaScript
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
|
|
*/
|