I'm looking for a solution to add multiple values to the same key in the map
Below is the requirement:
objs = new Map<string,obj>()
objs.set(obj.name,obj)
the values for key and value looks like below:
[pen,{pen,red,2}],[pencil,{pencil,yellow,1}],[pen,{pen,bule,3}]
so I'm setting value based on the name. Since I'm trying set value in the map, the duplicate key is overriding the value of the pen key. Now I want to append the value of duplicate key to the existing key. Is there a way to achieve it in javascript?
I'm expecting the result as below:
[pen,[{pen.red,2},{pen,blue,3}]],[pencil,{pencil,yellow,1}]
Can someone help me with this?