I am trying to comvert an array that has key value pairs into a simple object that only has the data (no keys).
I have an array like this...
[
0:{pos: 0, color: "#4a55e5"}
1:{pos: 0.2, color: "#206bcb"}
2:{pos: 0.4, color: "#edffff"}
3:{pos: 0.6, color: "#ffaa00"}
4:{pos: 0.8, color: "#000200"}
5:{pos: 1, color: "#000764"}
]
I need to convert it so that it is like this...
colorStops = {
0: "#4a55e5",
0.2: "#206bcb",
0.4: "#edffff",
0.6: "#ffaa00",
0.8: "#000200",
1: "#000764"
}
I guess I need to loop through the array and somehow push the values into the object...
colorStops = {};
for(var i=0; i<color.length; i++){
colorStops[i] = color[i].pos : color[i].color;
}
I only included this to better illustrate what I want. Of course this doesn't work and results in an error.