JSFiddle - React, Tailwind, and code Playground

by David Santiago

JavaScript

const exercises = [
  {
    date: "2023-03-14T11:26:52.000Z"
  },
  {
    date: "2023-03-21T11:26:52.000Z"
  },
  {
    date: "2023-03-21T11:26:52.001Z"
  },
  {
    date: "2023-03-21T11:26:52.002Z"
  },
  {
    date: "2023-03-28T11:26:52.002Z"
  },
  {
    date: "2023-04-04T11:26:52.002Z"
  }
];

const resultObject = {};

exercises.map(item => {
if(resultObject.hasOwnProperty(`${item.date.substring(0,10)}`)){
resultObject[`${item.date.substring(0,10)}`]++
}else{
resultObject[`${item.date.substring(0,10)}`] = 1
}
});

console.log(Object.keys(resultObject).length);