3. Displaying people




When I call this code it says: "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?" And on the black window it says: "undefined undefined". I wonder what is wrong with it?

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 = [0, 1];

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


first off, your contacts array:

var contacts = [0, 1];

should actually hold your contacts:

var contacts = [bob,mary];

now we can use this on our function call, lets see what you have at the moment:


a function call requires normal brackets:


this will pass an argument into the function call. Now, we need to access the first item of our contacts array, and pass this as function argument.


Ok, now it works, thanks. There is a text on green "Way to go!" and on the black box it reads: "Bob Jones undefined
Mary Johnson undefined".


wow, you made it to work. Most of the time people need more help when my answer is just a push in the right direction, truly, well done :slight_smile:

oh, the instructions warn you for this:
Don't worry if your output appears twice - we're just double checking your code!

Your code works fine, i got the same output.


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