I'm faced with an array conundrum
categories: [
{
name: 'category1',
items: 0,
},
{
name: 'category2',
items: 0,
},
{
name: 'category3',
items: 0,
},
]
And then there's this separate array
items: [
{
name: 'Item1',
email: '<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="caa8a6aba8a6ab8aada7aba3a6e4a9a5a7">[email protected]</a>',
category:'category1'
},
{
name: 'Item2',
email: '<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="88e4e9e4e9e4e9c8efe5e9e1e4a6ebe7e5">[email protected]</a>',
category:'category2'
},
{
name: 'Item3',
email: '<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="97f8f8f8f8d7f0faf6fefbb9f4f8fa">[email protected]</a>',
category:'category2'
},
]
Now, I'm struggling with determining the count of items in each category. I've attempted using map and filter functions, but so far, no luck.
My Expectation
I anticipate a function to update the categories array accordingly with the correct item count.