12. Practice makes perfect


#1



SyntaxError: missing before statement

Where is the mistake?

for(i=0;i<4;i++)
    {
        var object[i] = new Object();
        object[i].name = ("Daniel" + [i]);
        console.log(object[i].name)
    };


#2

for(i=0;i<4;i++)
{
var object[i] = new Object();
object[i].name = ("Daniel" + [i]);
console.log(object[i].name);
};


#3

same errormessage:cry:


#4

what is this line:

var object[i] = new Object();

suppose to do?


#5

I wanted to create 3 objects, object1, object2 and obejct3. I tried to force the loop to put his iterator [i] to use it in the name of the new object, so object[i] should become object1, object2.


#6

i tried that when i was in my early stages when i was programming. i got some bad news, It doesn't work that way unfortunately.

You could use an array:

objectArray = [];
for(i=0;i<4;i++){
    objectArray[i] = new Object();
}

i will leave the rest to you


#7

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.