I have a function that I have written which takes numbers in array and finds the mean eg mean([1,2,3,4,5]) === 3
or mean([1,10]) === 5.5
but what adjustments can I make it I want to find the mean of nothing. So I would my final result to look like this mean([]) === null
function mean(arr) {
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 * arr) / arr.length;
}
Any help is much appreciated.