11/17


#1

var me = new object();
me["name"] = "Faisal";
me["age"] = 17;
whats gone wrong? need help


#2

The correct code is:-

var me = new Object();

me.name = "Faisal";
me.age = 17;

#3

You need to write object with an uppercase "O"

var me = new Object();

#4

the way he wrote it worked for me and his "O" is uppercase right it looks like it to me


#5

Try this, 'Start next lesson' :smile: !!!

var me=new Object();

console.log( me.name="Jay");
console.log( me.age=22);


#6

I didn't want to correct @gtbsg2k1's code but the OP's. I just wanted to emphasize the mistake because @gtbsg2k1 just provided the code.


#7

I did this and it only prints out my age.


#8

var me = new Object();
me.name = "Russik";
me.age = 27;
console.log (me); //{ name: 'Russik', age: 27 } I don't know why it looks like this but you can see your name and age


#9

Actually this:

{ name: 'Russik', age: 27 }

is what you're object looks like in literal notation.


#10

@aledavila did you manage to work out why it only prints out your age ? The reason I ask is that it has does exactly the same with me.


#11

Experienced the same here.

Is this a bug or something? Did I do anything wrong?


#12

One resolution to call both me objects:


#13

the reason why it only print your age on screen is becuase you have to console.log it.
just like the previous one. :slightly_smiling:


#14

One question.

Why in the demo code of this section, they didn't declare new Object.

What they wrote is only as following:

var photoEntry = {};

instead of

var photoEntry = new Object();