Q:

Removing duplicates elements with conditionality

I have an array of objects that look like this:
[
    { project: "test1", date: "8/14/2018" },
    { project: "test1", date: "8/15/2018" },
    { project: "test2", date: "8/14/2018" }
]

I want to remove duplicate objects based on the project name, BUT, keep the one with the most recent date.
So my final array would like this:
[
    { project: "test1", date: "8/15/2018" },
    { project: "test2", date: "8/14/2018" }
]

I've come up with a disgruntled recursive solution that I'm unhappy with. 
Looking for suggestions on a painless way to do this.

A:

The approach I generally take for problems like this is to maintain a "dictionary" object to track uniqueness while iterating through, then extract the final result from that result. reduce is the go-to tool for creating one value from multiple values:
const dict = objects.reduce((result, item) => {
  const currentForProject = result[item.project];
  const isMostRecent = 
      !currentForProject
      || new Date(item.date) > new Date(currentForProject.date);
  if (isMostRecent) {
    result[item.project] = item;
  }
  return result;
}, {});

const mostRecents = Object.values(dict);

