Where would i make object 2 defined?


#1

My code

var myObj = {
    object1: "Jeremiah",
    object2: "16",
    object3: 11
};
var myObj = {};
myObj.object1 ="Jeremiah";
myObj[object2] = "16"
myObj[object3] = 11;
var myObj = new Object();
myObj.object1 = "Jeremiah";
myObj[object2] = "16";
myObj[object3] = 11;

#2

Your missing semi colons >> ; << :wink:


#3


thanks!.


#4

//create an object with 3 properties object1-3
var myObj = {
    object1: "Jeremiah",
    object2: "16",
    object3: 11
};
var myObj = {}; // ... and it is replaced with an empty object :/ 
myObj.object1 ="Jeremiah"; // OK
myObj[object2] = "16" // object2 variable is not yet defined error. Better use "object2"
myObj[object3] = 11; // same here
var myObj = new Object(); // ... yet again replaced the myObj object with an empty one
myObj.object1 = "Jeremiah"; // OK
myObj[object2] = "16"; // same as above
myObj[object3] = 11; //same as above