Arrays and objects 11, pls help


#1

heres my code

var me = {
me.name = "Katherine";
me.age = 13;
var me = new Object();


#2

I'm not sure about the

var me = new Object();

part but you're using literal notation which means it should be this.

var me = {
name: "Katherine", <--- use just variable name with : instead of = and a , instead of a ;
age: 13 <--- same as above, but no semi colon.
}; <--- semi colon goes here


#3

oh i did not know that


#4

its still not working


#5

Can you send a link to your lesson that you're on? and what error messages are you getting?


#6

https://www.codecademy.com/courses/javascript-beginner-en-9Sgpi/2/3?curriculum_id=506324b3a7dffd00020bf661


#7

error: missing } after property list


#8

Okay I misunderstood. This is what your code should look like.

var me = new Object();
me.name = "Katherine";
me.age = 13;

var me = new Object(); creates the object and calls it "me". It has no parameters or properties or attributes.

then wherever you want you would use (only for constructor, not literal, as in this case) the dot seperater or bracket.
me.name = "Katherine"; (don't forget semicolon!
or
me["name"] = "Katherine"; also works. Similar to age.


#9

so should i do [] to age or keep what im doing


#10

It doesn't matter for this particular object.

you can still use me.age = 13, etc.

Later on there is a difference so keep the [ ] notation in mind.


#11

now i got this error

error missing : after property id


#12

You ONLY need to use the code

var me = new Object();
me.name = "Katherine";
me.age = 13;

nothing else. It works for me. Try refreshing your browser.


#13

thanks that really help


#14

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