Question: I have array like this:

```
var data = [[]];
var dataIndex = ['a','b','c'];
var data0 = [1,2,3];
var data1 = [4,5,6];
var data2 = [7,8,9];

```

I want to make that array to be like this:

```
data['a'] = [1,2,3];
data['b'] = [4,5,6];
data['c'] = [7,8,9];

```

I've tried with this code, but it doesn't work.

```
for(var i=0;i<dataIndex;i++){
   data[data[i]].push('data'+i[i]);
}

```

I don't know to do that in javascript since I'm new on this. Anyone can help me? thank you.

Answer: 
By Using function and loop.

```js
var data = {};
var dataIndex = ['a','b','c'];
var data0 = [1,2,3];
var data1 = [4,5,6];
var data2 = [7,8,9];

function covert(){
  const allData = [data0,data1,data2]
  dataIndex.forEach((item,i)=>{
    data[item] = allData[i];
  })
}
covert();
console.log(data)
```
You can just do it like this then. No need for loops

```
var data0 = [1,2,3];
var data1 = [4,5,6];
var data2 = [7,8,9];

var data = {
  a : data0,
  b : data1,
  c : data2
};

```