actionscript 3 - Sum of all even values of an array?AS3 -


i need sum values array, here example of it:

array (   [0] => 1   [1] => 1   [2] => 1   [3] => 1   [4] => 4   [5] => 6   [6] => 6 ) 

looking way sum same value:

array (   [1] => 4   [4] => 1   [6] => 2 ) 

any ideas?

var buckets:object = {};  var data:array = [1, 1, 1, 1, 4, 6, 6];  for(var i=0; i<data.length; ++i) {     if(!buckets[data[i]]) {         buckets[data[i]] = 1;     } else {         buckets[data[i]]++;     } }  trace(buckets); 

Comments

Popular posts from this blog

android - Get AccessToken using signpost OAuth without opening a browser (Two legged Oauth) -

org.mockito.exceptions.misusing.InvalidUseOfMatchersException: mockito -

android - IBM Worklight 6.1 [Application Error] There was a network error (file:///android_asset/www/index.html) -