Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

get average and sum javascript

var sum = array.reduce((a, b) => a + b, 0);	//get sum of all elements in array
var avg = (sum / array.length) || 0; //get average of all elements in array ;)
Source by dev.to #
 
PREVIOUS NEXT
Tagged: #average #sum #javascript
ADD COMMENT
Topic
Name
1+7 =