Arrays have always been a challenging aspect for me, so I would really appreciate any assistance. 😊
Complicating matters further, I need help with a WebOS application that has specific limitations:
- JavaScript 5.0
- The only additional library allowed is JQuery
- No arrow functions (=>)
Here is an example of the array I have to work with:
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"
}]
This is the desired format of the converted array:
var ScheduleFormatted = [{
"category": "Laboratory", "complete": "3", "total": "4" }, {
"category": "Radiology" , "complete": "1", "total": "2" }, {
"category": "Doppler" , "complete": "1", "total": "1" }, {
}]
It's important to note that I would like the incomplete categories to be listed first.
While I have managed to accomplish certain aspects like obtaining unique properties or counting instances by status, the overall complexity has me stuck.
Your help would be greatly appreciated.