StylishBrokenEmeraldtreeskink

const test = [
  {title: 'one', category: 'stuff', posted: '2017-06-15'},
  {title: 'two', category: 'things', posted: '2017-05-12'},
  {title: 'three', category: 'things', posted: '2017-06-15'},
  {title: 'four', category: 'crap', posted: '2017-06-06'},
  {title: 'five', category: 'stuff', posted: '2017-04-15'},
  {title: 'six', category: 'stuff', posted: '2017-05-15'},
  {title: 'seven', category: 'things', posted: '2017-06-10'},
  {title: 'eight', category: '', posted: '2017-06-13'}
];

function copyArrayOfObjects(objArr) {
  return [...objArr]
    .map(obj => {
      return Object.assign({}, obj);
    });
}

function aggregateArrayOfObjects(objArr, field) {
  let aggregated = [];
  let intermediateMap = {};
  
  objArr.forEach(item => {
    if(intermediateMap.hasOwnProperty(item[field])) {
      intermediateMap[item[field]] += 1;
    } else {
      intermediateMap[item[field]] = 1;
    }
  });
  
  for(let i in intermediateMap) {
    aggregated.push({name: i, total: intermediateMap[i]});
  }
  
  return aggregated;
}

const archiveFirst = copyArrayOfObjects(test)
  .map(b => {
    b.posted = b.posted.slice(0, 7);
    return b;
  });
const archive = aggregateArrayOfObjects(archiveFirst, 'posted');
console.log(archive);

const categoriesFirst = copyArrayOfObjects(test)
  .map(b => {
    if(!b.category) { b.category = 'None'; }
    return b;
  });
const categories = aggregateArrayOfObjects(categoriesFirst, 'category');
console.log(categories);