I've done some research on various platforms, but haven't come across a solution to my specific issue. I'm looking to extract objects from an array and group them by their names in order to calculate the total hours for each matching object.
Consider this array:
var arr = [{name: 'Apple', hours: 6}, {name: 'Nokia', hours: 8},
{name: 'Apple', hours: 4}, {name: 'Nokia', hours: 12},];
//expected output: [{name: 'Apple', totalHrs: '10'}], [{name: 'Nokia', totalHrs:
'24'}]
Any assistance would be greatly appreciated.