calculate the total of all numbers in Array


/ Published in: ActionScript 3
Save to your folder(s)



Copy this code and paste it in your HTML
  1. // returns the total of all numbers in array as 1 number
  2. private function arrayTotal(input:Array):Number
  3. {
  4. var total:Number = 0;
  5. for(var i:Number = 0; i < input.length; i++)
  6. {
  7. total += Number(input[i]);
  8. }
  9. return total;
  10. }

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.