Check out example codes for "Tushar Jadhav". It will help you in understanding the concepts better.

Code Example 1

var arr = [];
var fruits = ['banana', 'apple', 'mango'];
var label = 'Fruits';

for (var i = 0; i < fruits.length; i++) {
    var obj = {};
    obj['data'] = fruits[i];
    obj['label'] = label;
    arr.push(obj);
}

Code Example 2

var arr = fruits.map(fruit => ({
    data: fruit,
    label: label
}));

Code Example 3

for(var i = 0; i < fruits.length; i++) {
    var obj = {}; // <---- Move declaration inside loop

    obj['data'] = fruits[i];
    obj['label'] = label;
    arr.push(obj);
}

Learn ReactJs, React Native from akashmittal.com