Skip to main content
Inspiring
January 10, 2012
Answered

Sum of an array

  • January 10, 2012
  • 1 reply
  • 837 views

Hey guys,

So I have an array with six values stored in them.

The values will either be 1 or 0.

I need to sum them up so that I get a number ranging from 0-6.

Any help on this rather noob question would be much appreciated!

This topic has been closed for replies.
Correct answer Ned Murphy

just loop thru the array and add them up...

var arraySum:Number = 0;

for (var i:uint=0; i< yourArray.length; i++){

     arraySum += yourArray;

}

1 reply

Ned Murphy
Ned MurphyCorrect answer
Legend
January 10, 2012

just loop thru the array and add them up...

var arraySum:Number = 0;

for (var i:uint=0; i< yourArray.length; i++){

     arraySum += yourArray;

}

RobulonZAuthor
Inspiring
January 10, 2012

Ned = Hero of the day.

Cheers buddy!