I have a function that returns an object like (key is string and value is array of strings):
{"myType1": ["123"]}
I want to merge all the results its returning for example - if I have:
{"myType1": ["123"]}
{"myType2": ["456"]}
{"myType1": ["789"]}
I'd like to get
{"myType1": ["123", "789], "myType2": ["456"]}
I've seen Object.assign however that doesn't merge the values it just replaces with the most recent.
Has anyone got an examples of how I can achieve this?
Any help appreciated.
Thanks.
{"myType1": ["123"]}, as each object is being recieved I want to collage into one