I have an array of JSON objects. However, some of the data is repeated. Is there a way to restructure the array to exclude repeated values? Do I have to use the Map function? or a for loop?
userData = [{id:'101', Time:'3:00pm', Date:'5/25/20'},
{id:'101', Time:'5:00pm', Date:'5/25/20'},
{id:'101', Time:'5:00pm', Date:'6/25/20'},
{id:'105', Time:'1:00pm', Date:'3/25/20'},
{id:'105', Time:'5:00pm', Date:'5/25/20'}
]
Is it possible to restructure the data like so?
userData = [ {id:'101', Time:['3:00pm','5:00pm'], Date:['5/25/20', '6/25/20']},
{id:'105', Time:['1:00pm','5:00pm'], Date:['3/25/20','5/25/20']}
]
If you have any guidance or direction, it would be greatly appreciated! Thank you!
TimeandDateseparately? In my experience, in most use cases times make sense only on a certain day.