Displaying People error [SOLVED]


#1

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

I keep receiving an error message that states: "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?"

The results screen shows the following:
Bob 0Jones
Mary 0Johnson
0

I'm unsure what I'm doing wrong. I've viewed other requests for help and my code appears to match others that has passed this exercise. Can someone help?


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


#2

Ok, I retyped my code and it works now. I'm still curious what my original error is.


#3

What change did you make? In my code, I made a personArray variable with Bob Jones and Mary Johnson in it and called my contacts from that but since your calling yours from your actual variable contact I was thinking maybe putting Bob Jones and Mary Johnson in the contacts might work.


#4

here:

console.log(person.firstName, + " " + person.lastName);

you have a comma (,) after firstName, which caused the error


#5

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