Need help with 3. Displaying People


#1


https://www.codecademy.com/courses/building-an-address-book/0/3?curriculum_id=506324b3a7dffd00020bf661#


It's only printing Mary to the console. Not sure why?
Error message: It looks like your function didn't log "Bob Jones" to the console. Did you remember to call your function on bob?


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

printPerson(contacts[0]);
printPerson(contacts[1]);


#2

i have the exact same problem! same code, everything.

what's wrong..?


#3

must be:

var printPerson = function(person) {

#4

The way you set up your function is wrong. You define your function with two different names: myFunction and printPerson. Where does function name myFunction come from? The code should of been like below with function printPerson:

var printPerson = function (person) {
console.log(person.firstName + " " + person.lastName);
}

// then you can call your function:

printPerson(contacts[0]);
printPerson(contacts[1]);

hope it helps :slight_smile:


#5

thanks that fixed it!!!


#6

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