11. What is wrong with my code?



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.


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).


Thanks! This solves it.


You're welcome, happy coding!