tushar jadhav

Solutions on MaxInterview for tushar jadhav by the best coders in the world

showing results for - "tushar jadhav"
Kris
23 Apr 2019
1var arr = fruits.map(fruit => ({
2    data: fruit,
3    label: label
4}));
Camilla
12 Jul 2020
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}
Ivan
19 Feb 2018
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}
similar questions
queries leading to this page
tushar jadhav