Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

THE REDUCE() METHOD IN JAVASCRIPT

/*
This method takes a callback that takes two parameters,
one that represents the element from the last iteration and the other is the current
element of the iteration
*/

let nums = [2,4,6,8,3,5]

let result = nums.reduce((prev,curr)=>prev+curr)
console.log(result); // 28
Source by blog.devgenius.io #
 
PREVIOUS NEXT
Tagged: #THE #METHOD #IN #JAVASCRIPT
ADD COMMENT
Topic
Name
5+4 =