Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

complicated reduce

var valeurInitiale = 0;
var somme = [{x: 1}, {x:2}, {x:3}].reduce(function (accumulateur, valeurCourante) {
    return accumulateur + valeurCourante.x;
}, valeurInitiale);

console.log(somme); // affiche 6 dans la console
Source by developer.mozilla.org #
 
PREVIOUS NEXT
Tagged: #complicated #reduce
ADD COMMENT
Topic
Name
2+6 =