score:0

const arr = [
    { createdAt: "08-08-2020, 12:04:19 am", id: "1" },
    { createdAt: "08-08-2020, 12:04:19 am", id: "2" },
    { createdAt: "08-10-2020, 12:04:19 am", id: "3" },
    { createdAt: "08-10-2020, 12:04:19 am", id: "4" },
    { createdAt: "08-12-2020, 12:04:19 am", id: "5" },
    { createdAt: "08-20-2020, 12:04:19 am", id: "6" }
];
const res = Object.values(
  arr.reduce((acc,{createdAt, id})=>{
    const date = createdAt.split(",")[0];
    acc[date] = acc[date] || {createdAt: date, ids: []};
    acc[date].ids.push(id);
    return acc;
  }, {})
);
console.log(res);

score:1

const resultingArray = Object.entries(map).map(([createdAt, ids]) => ({
  createdAt,
  ids
}))

Related Query

More Query from same tag