Displaying people


#1

When I run the below program it is saying Syntax error: Unexpected String.
Please tell me where the mistake is.

var bob =
{
firstName: "Bob",
lastName: "Jones",
phoneNumber: "(650) 777-7777",
email: "bob.jones@example.com"
};

var mary =
{
firstName: "Mary",
lastName: "Johnson",
phoneNumber: "(650) 888-8888",
email: "mary.johnson@example.com"
};

var contacts = [bob, mary];

// printPerson added here
var printPerson=function(person)
{
console.log(contacts[person].firstName" "+" "contacts[person].lastName);
}

printPerson(0);
printPerson(1);


#2

@vijaycodecademy,

Have a close look at ....(error in concatenation with + sign)

contacts[person].firstName" "+" "contacts[person].lastName


#3

the keys are misplaced
var mary =
{
firstName: "Mary",
lastName: "Johnson",
phoneNumber: "(650) 888-8888",
email: "mary.johnson@example.com"
};
it is incorrect
var mary = {
firstName: "Mary",
lastName: "Johnson",
phoneNumber: "(650) 888-8888",
email: "mary.johnson@example.com"
};
var mary =
{
firstName: "Mary",
lastName: "Johnson",
phoneNumber: "(650) 888-8888",
email: "mary.johnson@example.com"
};
var mary =
{
firstName: "Mary",
lastName: "Johnson",
phoneNumber: "(650) 888-8888",
email: "mary.johnson@example.com"
};
is correct


#4

var mary = {
firstName: "Mary",
lastName: "Johnson",
phoneNumber: "(650) 888-8888",
email: "mary.johnson@example.com"
};
is correct