Having a JSON object array with various project information:
[
{"Project":"Project 1","Domain":"Domain1","Manager":"Manager1"},
{"Project":"Project 2","Domain":"Domain2","Manager":"Manager2"},
{"Project":"Project 3","Domain":"Domain3","Manager":"Manager1"},
{"Project":"Project 4","Domain":"Domain1","Manager":"Manager3"},
{"Project":"Project 5","Domain":"Domain5","Manager":"Manager4"},
{"Project":"Project 6","Domain":"Domain6","Manager":"Manager5"},
{"Project":"Project 7","Domain":"Domain5","Manager":"Manager2"},
{"Project":"Project 8","Domain":"Domain2","Manager":"Manager5"},
{"Project":"Project 9","Domain":"Domain7","Manager":"Manager8"},
{"Project":"Project 10","Domain":"Domain9","Manager":"Manager9"},
{"Project":"Project 11","Domain":"Domain6","Manager":"Manager1"}
]
I need to extract all distinct domains and managers into separate string arrays.
Here is my approach:
let Domains:string[]=[];
Domains= res.map((x)=>x.Domain);
let Managers:string[]=[];
Managers= res.map((x)=>x.Manager);
The current implementation works, but there are duplicate values in both arrays.
Is there a better way to assign these variables using a single map function instead of assigning them separately?