Question: I have a list of values that I want to dynamically assign to another list of values:

```
var activeMachines = [41,44,46]

for(i = 0; i < activeMachines.length; i++){
    var temp + activeMachines[i] = document.getElementById("tempData"+activeMachines[i]);
    var humid + activeMachines[i] = document.getElementById("humidData"+activeMachines[i]);
    var time + activeMachines[i] = document.getElementById("timeData"+activeMachines[i]);
 }

```

What I am hoping to achieve is that this loop would create 6 new variables in total:

```
temp41 = document.getElementById("tempData41");
temp44 = document.getElementById("tempData44");
...

```

Above is not working. I have read some other posts suggesting using arrays, but I think I need to somehow dynamically create a dictionary, and I can't seem to get the syntax right to achieve this. any suggestions?

Answer: 
You can use the `window` object for doing that, however, I recommend you to create your own object to store those "variables" as properties within that new `key-value` object.

```
var activeMachines = [41,44,46]
var obj = {};

for(i = 0; i < activeMachines.length; i++){
    obj['temp' + activeMachines[i]] = document.getElementById("tempData"+activeMachines[i]);
    obj['humid' + activeMachines[i]] = document.getElementById("humidData"+activeMachines[i]);
    obj['time' + activeMachines[i]] = document.getElementById("timeData"+activeMachines[i]);
 }

```
You can use an object and create properties instead of variables.

```
var context = {};
for (i = 0; i < activeMachines.length; i++) {
    context[`temp${activeMachines[i]}`] = document.getElementById("tempData"+activeMachines[i]);
}

```

And the access those data with `context.temp41` or `context["temp41"]`