- Home /
This question was
closed Sep 03, 2013 at 01:13 PM by
Fattie for the following reason:
File under "hyper-easy programming questions" :)
Find the average of a float array?
How could i get the average of a float array in javascript? var arr : float[];
Comment
Best Answer
Answer by Tanshaydar · Sep 03, 2013 at 09:01 AM
for( var i = 0; i < arr.length; i++) {
sum += arr[i];
}
average = sum / arr.length;
Sorry for reviving an old message but will this work in c# ?
If you declare your variables as
float sum = 0;
float average = 0;
before the loop, and then yeah.
Or you could just use the Average function in System.Linq. (Applies to both JS and C#.)
Follow this Question
Related Questions
How to convert 00:40:00.0 to float 2 Answers
HOW TO ADD AND REMOVE VARIABLES ALREADY DECLARED IN A LIST 1 Answer
Display a float number when button is clicked 4 Answers
Bone Rotation on X (or any) axis Issues 1 Answer
InvokeRepeating help 2 Answers