Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

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
Source by oprea.rocks #
 
PREVIOUS NEXT
Tagged: #rest #operator #javascript
ADD COMMENT
Topic
Name
1+3 =