var counts = usedColors
  .map(function(color) {
    var count = {};
    count[color] = 1;
    return count;
  })
  .reduce(function(a, b) {
    Object.keys(a).forEach(function(key) {
      if (key in b) {
        b[key] += a[key];
      } else {
        b[key] = a[key];
      }

      return b;
    });
  });