JavaScript · Junior · Question 29 of 75
What does sum(1, 2, 3) return?
function sum(...nums) {
return nums.length;
}- ✓Correct answer:
3 - 2
1 - 3
6
Explanation
A rest parameter collects the remaining arguments into a real array. Unlike the legacy arguments, it's an array with map and reduce, and it works in arrow functions.