I would like to know if there is a efficent way to wrtie this type of code to filter an array of objects.
Currently if have a lot of lines of duplicated code. Not that sexy, i know.
let ab_without_status = data.filter(function(el){
return el.UNC_Leader === "AB" && el.Status === ""
})
let ab_canceled = data.filter(function(el){
return el.UNC_Leader === "AB" && el.Status === "canceled"
})
let ab_closed = data.filter(function(el){
return el.UNC_Leader === "AB" && el.Status === "closed"
})
let ab_on_hold = data.filter(function(el){
return el.UNC_Leader === "AB" && el.Status === "on hold"
})
let ab_open = data.filter(function(el){
return el.UNC_Leader === "AB" && el.Status === "open"
})
....
And this is just a small chunk of code. I have an array with around 80 different UNC_Leader, everyone of them with these 5 status – which means a lot of duplicated code.
In the end, i try to archieve to count every status for every UNC_Leader