Arguments // mean is a variadic function function mean(){ var sum = [].reduce.call(arguments, function(memo, n){ return memo + n; }, 0); return sum / arguments.length; } mean(1, 2, 3); // 2 mean(1); // 1 mean(3, 1, 4, 1, 5, 9, 2, 6, 5); // 4 mean(2, 7, 1, 8, 2, 8, 1, 8); // 4.625 // goal: compute the mean of the values in this list var array = [2, 7, 1, 8, 2, 8, 1, 8]; mean.apply(null, array); // 4.625