Answers for "Use the Rest Parameter with Function Parameters In order to help us create more flexible functions, ES6 introd"

6

javascript multiply arguments

const mul = (...args) => args.reduce((a, b) => a * b);

// Example
mul(1, 2, 3, 4);    // 24
Posted by: Guest on July-03-2020
7

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
Posted by: Guest on January-14-2020

Code answers related to "Use the Rest Parameter with Function Parameters In order to help us create more flexible functions, ES6 introd"

Code answers related to "Javascript"

Browse Popular Code Answers by Language