Syntax Error: Unexpected String!


#1



12. Practice makes perfect
https://www.codecademy.com/courses/javascript-beginner-en-9Sgpi/2/4?curriculum_id=506324b3a7dffd00020bf661#


SyntaxError: Unexpected string


var object1 = new Object ();
object1."name"="sherry";
object2."year"=2016;

var object2 = {
    sport: "tennis",
    art: "dance"
};

var object3 = new Object ();
object3["month"] = 3;
object3 ["name"]= "Bob";

Thanks a lot :slight_smile:


#2

it should be:

object1.name = "sherry";

object1.year= 2016;

remove the space before ["name"]


#3

Thank you! It worked! But why it only print out "Bob" now? @puristaja


#4

the codecademy editor logs out the property value of the object property declared on the last line. I don't know why. Probably just a safety check.