I am not very comfortable in JavaScript. This question may be silly, but I could not find any suitable solution.
I have following two arrays.
colors = ['red', 'green', 'blue'];
values = [20, 50, 100];
Now I want to convert it into a data series, something like,
data: [{
color: 'red',
value: 20,
}, {
color: 'green',
value: 50,
}, {
color: 'blue',
value: 100,
}]
I looked JSON.stringify() and jQuery.param() functions, but not clear how to accomplish this.
data,color,valueetc. are parameters, not a string. So probably I am looking for a function that generates parameter-value combination from arrays and can be used in another function.