Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

calculate average 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 stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #calculate #average #javascript
ADD COMMENT
Topic
Name
8+1 =