Skip to content

Challenge Condense Arrays With Reduce

Quincy Larson edited this page Aug 20, 2016 · 1 revision

Challenge Condense Arrays with Reduce

Reduce can be useful for condensing an array of numbers into one value.

var array = [4,5,6,7,8];
var singleVal = 0;
// Only change code below this line.

var singleVal = array.reduce(function(previousVal, currentVal){

  return previousVal+currentVal;

});
Clone this wiki locally