11. What is wrong with my code?


#1



https://www.codecademy.com/courses/spencer-sandbox/1/6?curriculum_id=506324b3a7dffd00020bf661#


This is my code:
// help us make snoopy using literal notation
// Remember snoopy is a "beagle" and is 10 years old.
var snoopy = {
species: "beagle",
age: 10
};

// help make buddy using constructor notation
// buddy is a "golden retriever" and is 5 years old
var buddy = new Object{};

buddy.species = "golden retriever";
buddy.age = 5;

When I hit Submit, I get following SyntaxError: Unexpected token {
I tried to refresh the page (using F5 and Ctrl + F5) but get the same error again.

I'd very much appreciate your help.

Thank you


Replace this line with your code.


#2

var buddy = new Object()

This is the correct way to write it. You shouldn't be using curly braces here, it is a function and should thus be written with round brackets (parentheses).


#3

Thanks! This solves it.


#4

You're welcome, happy coding!