Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

reduce javascript

//note idx and sourceArray are optional
const sum = array.reduce((accumulator, element[, idx[, sourceArray]]) => {
	//arbitrary example of why idx might be needed
	return accumulator + idx * 2 + element 
}, 0);
Source by developer.mozilla.org #
 
PREVIOUS NEXT
Tagged: #reduce #javascript
ADD COMMENT
Topic
Name
1+5 =