add value to each object in array javascript

Solutions on MaxInterview for add value to each object in array javascript by the best coders in the world

showing results for - "add value to each object in array javascript"
Ignacio
05 May 2016
1var labels = ["DESKTOP", "MOBILE", "TABLET"];
2var chartData = ["100", "10", "15"];
3var myData = [];
4
5labels.forEach(function(e, i) {
6  myData.push({
7    label: e,
8    data: chartData[i]
9  })
10})
11
12document.write(JSON.stringify(myData));