Iterating the dates array to create a new array with the following format
const dates= [
{datetime:'Monday'},
{datetime:'Tuesday'},
{datetime:'Wednesday'},
{datetime:'Thursday'},
{datetime:'Monday'},
{datetime:'Wednesday'},
{datetime:'Friday'},
{datetime:'Monday'}]
// Result
result = [ { x: 'Monday', y: 3 },
{ x: 'Tuesday', y: 1 },
{ x: 'Wednesday', y: 2 },
{ x: 'Thursday', y: 1 },
{ x: 'Friday', y: 1 } ]
question from:
https://stackoverflow.com/questions/65623382/how-to-sort-array-of-repeated-object-keys-day-values-and-create-a-new-array-with 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…