You're on the right track.
…
var obj = {
for(var j=0; j
That's a syntax error. You can't put the for-loop in the middle of the object literal. Instead, create the empty object in one step and then fill it with the properties by assignment (using bracket notation) in the loop:
…
var obj = {};
for(var j=0; j