I would like to transform the following array which is dynamic to an dynamic object
e.g.
let
array=[{"MyFirstValue":"1"},{MySecondvalue:"2"}]
I would like to convert it ti an dynamic object
like
let newobject={MyFirstValue:"1",MySecondvalue:"2" }
The dynamic object here is that depending upon the numbers of values in the array the newobject should be able to transform e.g.
if the array value changes =
array=[{"MyFirstValue":"1"},{MySecondvalue:"2"},{MyThirdValue:"2"}]
The newobject should transform to
newobject={MyFirstValue:"1",MySecondvalue:"2",MyThirdValue:"2" }
I tried using array.map and pushing the value but could not set the key property
It is like reducing the reducing the array to an object. I am not sure if i can use reduce.