what do i do now to find the average of a given array of numbers?
function avgValue (array) {
var sum = 0;
for (var i = 0; i <= array.length; i ++) {
sum += array[i]
}
return
}
what do i do now to find the average of a given array of numbers?
function avgValue (array) {
var sum = 0;
for (var i = 0; i <= array.length; i ++) {
sum += array[i]
}
return
}
For further actions, you may consider blocking this person and/or reporting abuse
TheDev -
Chipm0nk -
Bregwin Jogi -
Matek -
Top comments (2)
You've got the sum of the values. Now all you have to do is divide them by the number:
return sum / array.length;
That's it! ;)
function avgValue (array=[]){
let sum = 0;
array.forEach(number => {
sum += number;
})
return sum/array.length
}