I found this: count occurrences of search strings in a list (python) similar with solution i need but in javascript.
I have array of objects:
data_items = [
    {
        "no": "1",
        "category": "design",
        "class": "low",
        "status": "open",
    },
    {
        "no": "2",
        "category": "permit",
        "class": "low",
        "status": "close",
    },
    {
        "no": "3",
        "category": "permit",
        "class": "high",
        "status": "open",
    },
    {
        "no": "4",
        "category": "quality",
        "class": "high",
        "status": "close",
    }
]
    
and
categoryList = [
    "design",
    "permit",
    "quality",
    "safety",
    "commercial"
]
what I expected is to count occurrences each category includes the null result
countCategories = [
       { "design": 1 },
       { "permit": 2 },
       { "quality": 1 },
       { "safety": 0 },
       { "commercial": 0 }
]
and how do i get multidimension version of the result? such as
 countCategories = [
        {
            open: [
                { "design": 1 },
                { "permit": 1 },
                { "quality": 0 },
                { "safety": 0 },
                { "commercial": 0 }
            ]
        }, {
            close: [
                { "design": 0 },
                { "permit": 1 },
                { "quality": 1 },
                { "safety": 0 },
                { "commercial": 0 }
            ]
        }
    ]
I've been trying to get the result by reduce and filter, but got no luck
thank you for your help.
 
     
     
     
     
     
    