Use the Rest Parameter with Function ParametersPassed code example
Example: the rest operator javascript
function sum(...numbers) {
return numbers.reduce((accumulator, current) => {
return accumulator += current;
});
};
sum(1,2) // 3
sum(1,2,3,4,5) // 15