Object & Array Clarification



I am not receiving an error message. I am just looking for more clarification on two different matters.

Matter number 1:

After completing the proper code for a constructor object, the console only outputs the last assigned value. Like I said, it's not giving me an error message, but it seems odd that both of them do not get printed. If anyone has an explanation as to why ONLY one value prints out, please let me know so....

Matter number 2:

After getting the 'green light' to move on to the next lesson, my console window doesn't seem correct. Again, this can be an instance where it is correct, and I will find further information as to how I clean up the code, but I know codecademy has given me the "green light" in the past when I did not have the accurate answer.

Matter 1 

var help = new Object();
     help.name = "Peter";
     help.age = 31;

OUTPUT= 31  //<--- Where is "Peter"??

Matter 2

var obj = {};
     obj.name = "Ioana";
     obj.age = 31;

var myArray = [31, true, "Peter", obj];

OUTPUT / [ 31, true, 'Peter', { name: 'Ioana', age: 31 } ]

//Does that output seem correct??


It doesn't appear as though anything is being logged by your program, only the console itself. That's why it is only the last value assigned. Natural behavior, but can be ignored.

console.log(help);   // { name: 'Peter', age: 31 }

console.log(obj);    // [ 31, true, 'Peter', { name: 'Ioana', age: 31 } ]


Thanks Roy!,

So at this point the code is basic and supposed to look like that?


Everything looks fine. Yes, it is a basic introduction so don't expect anything to be complicated or abstract. Simplicity is the order of the day in this course.


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