args
array and allows us to apply map()
, filter()
and reduce()
on the parameters array.
sum
using the rest parameter in such a way that the function sum
is able to take any number of arguments and return their sum.
sum(0,1,2)
should be 3
testString: assert(sum(0,1,2) === 3);
- text: The result of sum(1,2,3,4)
should be 10
testString: assert(sum(1,2,3,4) === 10);
- text: The result of sum(5)
should be 5
testString: assert(sum(5) === 5);
- text: The result of sum()
should be 0
testString: assert(sum() === 0);
- text: The sum
function should use the ...
rest parameter on the args
parameter.
testString: assert(__helpers.removeWhiteSpace(code).match(/sum=\(\.\.\.args\)=>/));
```