1var arr = [];
2var fruits = ['banana', 'apple', 'mango'];
3var label = 'Fruits';
4
5for (var i = 0; i < fruits.length; i++) {
6 var obj = {};
7 obj['data'] = fruits[i];
8 obj['label'] = label;
9 arr.push(obj);
10}
1for(var i = 0; i < fruits.length; i++) {
2 var obj = {}; // <---- Move declaration inside loop
3
4 obj['data'] = fruits[i];
5 obj['label'] = label;
6 arr.push(obj);
7}