I'm trying to calculate a function that will return the average for an number of integer arguments. Who can help?
var Calculator = {
average: function(x) {
var num = 0;
for (var i = 1; i <= x.length; i++)
num = num + x[i];
var divide = num/x.length;
return divide;
}
};
When I run this code, I get NaN.
Here is the fiddle: http://jsfiddle.net/marcusdei/hsvr8va5/6/
--------------------> Update: Not a duplicate question or answer
Past answers do not support long floats.