Creating a New Object


#1



The program says it completed successfully, but the only thing printed to the console is 21. Kylo Ren is not printed. I tried doing a one-word name with no luck either. Please advise why both are not printing to the console.


var me = new Object();

me.name = "Kylo Ren";
me.age = 21;


#2

HI the CodeCademy console sometime log only the last line ..so if you want to print "Kylo Ren" you should do it like that

console.log(me.name); //this will print Kylo Ren
console.log(me.age); //this 21

Add it after your code.


#3

if you want it to print both values you must console.log the object by its name or both values seperately. :slight_smile:

The reason it brings back 21 is cause it by default will show the last line of your code when no console.log is indicated.


#4

Thank you both.
So, in professional practice, the way I did is correct?
I understand it only prints the last line now. :smiley: