Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

js .reducer 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 #method
ADD COMMENT
Topic
Name
8+1 =