JavaScript · Junior · Question 29 of 75

What does sum(1, 2, 3) return?

function sum(...nums) {
  return nums.length;
}

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.

Further reading

Problem with a question

JavaScript · Junior · question 29

Test yourself

Take the JavaScript · Junior quiz: questions and options are shuffled, and you get a review of your mistakes at the end.

Take this quiz