[Solved] add new properties to an object in for loop [closed]


So, for any newbies out there, this is the answer:

var myOBJ = {};
for (i=0; i<5; i++)
{
    //add new object on each loop
    myOBJ[i+"A"] = i + "loopnumber";
}

The final result will be:

myOBJ 
{
    0A : "0loopnumber",
    1A : "1loopnumber",
    2A : "2loopnumber",
    3A : "3loopnumber",
    4A : "4loopnumber"
};

4

solved add new properties to an object in for loop [closed]