Why doesnt this code work


#1

why doesnt this code work?

var snoopy = {
   species: "beagle"
   age: 10
};
var buddy = new Object();
buddy.species = "golden retriever";
buddy.age = 5
//unexcpected identifier

#2

All properties should be separated by comma:

var snoopy = {
   species: "beagle", // here
   age: 10 // the last prop doesn't have comma
};
var buddy = new Object();
buddy.species = "golden retriever";
buddy.age = 5

#3

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