I need to dynamically store pairs of values in a object. I have a code similar to:
obj = {};
avariable = "Name x";
anothervariable = 100;
var name = avariable;
var value = anothervariable;
obj[name] = value;
It does not work, the console.log shows: obj = [object Object]
I tried to look at this answer with a very similar problem, but I do not know in advance the "name" so I cannot use:
obj['name y']
My final goes is to store a value for each name and to restore those values later on with a loop given the name.