Building An Address Book lesson 3: is it a bug or is it me?


Building an address book, lessonn 3

When I test the code, I get the following output " It looks like your function didn't log "Bob Jones" to the console." But, it does log "Bob Jones." What am I doing incorrectly?

var bob = {
    firstName: "Bob",
    lastName: "Jones",
    phoneNumber: "(650) 777-7777",
    email: ""

var mary = {
    firstName: "Mary",
    lastName: "Johnson",
    phoneNumber: "(650) 888-8888",
    email: ""

var contacts = [bob, mary];

// printPerson added here
function printPerson(contacts) {
return (contacts.firstName + " " + contacts.lastName);    


Hi this line

lastName: "Jones",
Remove the space before the J in The string


is a reference object. It contains several references which is confusing to the program since it expects a single reference.

As we can see, this doesn't work out. contacts does not have any attributes of matter to offer. It is an array. The objects it references are what we are keen on.

You have called the function on an array. Let's ensure we don't cross that up by using the same name as our primary object. That would have consequences.

function printPerson(contact) {

in the singular. contacts is the object, contact is the member in that object we are looking up.


So I am getting the same error on this exercise. Here is a screenshot with my error message and code. I have looked through these boards and tried the various solutions, including @mtf's listed here but it is not helping.
Can someone take a look and see where I am going wrong?


The error may be triggered by the line above your function (which may be removed):

var printPerson = new Function();


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