Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

js reduce method

const arrayOfNumbers = [1, 2, 3, 4];
 
const sum = arrayOfNumbers.reduce((accumulator, currentValue) => {  
  return accumulator + currentValue;
});
 
console.log(sum); // 10
Source by www.codecademy.com #
 
PREVIOUS NEXT
Tagged: #js #reduce #method
ADD COMMENT
Topic
Name
6+2 =