Answers for "add value to each object in array javascript"

0

add value to each object in array javascript

var labels = ["DESKTOP", "MOBILE", "TABLET"];
var chartData = ["100", "10", "15"];
var myData = [];

labels.forEach(function(e, i) {
  myData.push({
    label: e,
    data: chartData[i]
  })
})

document.write(JSON.stringify(myData));
Posted by: Guest on July-14-2021

Code answers related to "add value to each object in array javascript"

Code answers related to "Javascript"

Browse Popular Code Answers by Language