3. Displaying People


I'm getting error message with my code saying: 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? here's my ouput:

{ firstName: 'Bob',
lastName: 'Jones',
phoneNumber: '(650) 777-7777',
email: 'bob.jones@example.com' }
{ firstName: 'Mary',
lastName: 'Johnson',
phoneNumber: '(650) 888-8888',
email: 'mary.johnson@example.com' }

and here's my code:

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);

Thanks for the help in advance.


Move these lines outside of the printPerson() function. They should call the function with the array element as arguments.


and so on.


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

thanks i figured it out.

here's whats wrong from the previous code:

function printPerson (person) { function error in this line.
console.log(person.firstName = " " + person.lastName); and the = in this line
console.log(contacts[1]); and like your suggestion moving this outside the printPerson function

Thanks again.


Hey @jdm316 glad you got it sorted. In future it would be great if you can use the format code button, will make it a lot easier for others to read!


@alexcraig ok will do.


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