var total = 0;
for(var i = 0; i < arr.length; i++) {
total += arr[i]
}
return total / arr.length
}
function round(number) {
return Math.round(total * 100) / 100;
}
mean([5,8,2,5,8,0,1,4])

The first function will return the average sum, in the case of this array 4.125 but by a decimal place. Any ideas how i can implement the second function to bring the number to a whole number.

The round function you wrote doesnâ€™t even use its argument so wonâ€™t do anything really, unless total is a global variable - but thatâ€™s probably not what you want.

You have shown you already know of a round function in the standard library, so why not use that?

and taking a look at the various rounding conventions there. I suppose it might be cheating in a sense to use Math.ceil etc, as they are technically a sort of rounding in themselves, but those can be implemented more nicely I guess as seperate functions.

But really, itâ€™s not worth it to go down that rabbit hole

Im not sure if Im asking it right, but I guess what Im trying to do is use the second function, to round the number that comes from executing the first function, while using Math.round(total * 100) / 100