Working with arrays is definitely one of my weakest area, so any help is greatly appreciated.
To add to the challange, this is for a WebOS application that has the following limitations ...
- JavaScript 5.0
- Only extra library is JQuery
- No arrow functions (=>)
Example of received array ...
var Schedule = [{
"category": "Laboratory", "status": "COMPLETE" }, {
"category": "Radiology" , "status": "COMPLETE" }, {
"category": "Laboratory", "status": "SCHEDULED"}, {
"category": "Laboratory", "status": "COMPLETE" }, {
"category": "Radiology" , "status": "SCHEDULED"}, {
"category": "Laboratory", "status": "COMPLETE" }, {
"category": "Doppler" , "status": "SCHEDULED"
}]
Desired conversion ...
var ScheduleFormatted = [{
"category": "Laboratory", "complete": "3", "total": "4" }, {
"category": "Radiology" , "complete": "1", "total": "2" }, {
"category": "Doppler" , "complete": "1", "total": "1" }, {
}]
It would be especially great to have the incomplete categories listed first.
I've been successful in achieving parts of this (like getting unique properties, or instance count by status), but the complexity of this has me completely stumped.
Please help.