3/6 displaying people


#1

Good morning! The system keeps telling me "Oops, try again. It looks like your function didn't log "Bob Jones" to the console. Did you remember to call your function on bob?"
Any guidance would be greatly appreciated!

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
function printPerson(person){
console.log (person.firstName + " " + person.lastName);
}

function printPerson(person) {
console.log (contacts[0]);
console.log (contacts[1]);

};

#2

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
function printPerson(person) {
console.log(person.firstName + " " + person.lastName);
}
printPerson(contacts[0]);
printPerson(contacts[1]);

Try this code. It works!


#3

This code is not running. It is necessary to change the function of print Person (person) to printPerson (contact)


#4

I did my function like this, seems more robust, but the editor didn't recognize it even though it works great:

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


#5

Sorry seems to be the code works.