The rest parameter syntax allows us to represent an indefinite number of arguments as an array.
Source Code
function sum(...numbers) {
return numbers.reduce((acc, current) => acc + current, 0);
}
console.log(sum(1, 2, 3));
The rest parameter syntax allows us to represent an indefinite number of arguments as an array.
function sum(...numbers) {
return numbers.reduce((acc, current) => acc + current, 0);
}
console.log(sum(1, 2, 3));