0
How do I input random numbers in array and then get their sum ?
4 Respuestas
+ 2
for a sum of them :
var sum, i;
for(i=0, i<arr.length, i++){
sum+= arr[i];
}
+ 1
try this:
var arr = [];
var rndNum = Math.round(Math.random()*x);
arr[arr.length]=rndNum;
**x is max number it can produce
Now, you can put last 2 lines in some kind of loop to do it faster.
+ 1
Thanks Amar
+ 1
Thanks bunches