Arrays and Objects in JS- What do I doing wrong?


#1


#2

You should end it with semi-colons like below:

var object1 = new Object();

object1.name = "Spy";

#3

I change to

object1.name = "Spy";
SyntaxError: Unexpected token :


#4

Not a colon (:)please. A semi-colon (;).

Please post full code.


#5

Here,

var object1 = new Object();
object1.name = "Spy";
object1.age = 50;
console.log(object1);

And I get an output of:

{ name: 'Spy', age: 50 }

Please use above to replicate.


#6

Thanks for your help.
One more thing when I type new object instead of new Object, it come out [ReferenceError: object is not defined], why need type (Object) capital.


#7

JavaScript is case sensitive and so because it is written so, you have to also do as.


#8

ok!
Thank you very much


#9

You're welcome!

Have fun coding! :slight_smile: