14 Building Address, #3


#1

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

contacts[0] = bob;
contacts[1] = mary;

// printPerson added here
var firstPerson = function(person) {
return person.firstName + " " + person.lastName;
};

console.log(printPerson(bob));

console.log(printPerson(mary));

14 building an address book, #3


Both names lof to console. Errow code says ' It looks like you did not log Bob Jones to the console. Check your function'. Please help. I have reviewed a number of other corrections of this exercise and not found anyuthing else that works!


Replace this line with your code.


#2

I just saw the printPerson and changed it to firstPerson, with the same results as above.


#3
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];

contacts[0] = bob;
contacts[1] = mary;

Revision of the code to do the function printPerson. Same results.
// printPerson added here
function printPerson(person) {
return person.firstName + " " + person.lastName;
}

console.log(printPerson(bob));

console.log(printPerson(mary));


#4

Those two lines are not needed. bob and mary references are already in the array.

The exercise wants us to use the contacts array when logging bob and and mary.

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

#5

Thanks for the reply. I think I did this before. I made the changes and 'Bob Jones' does not log to the console and I get the same error message. Other thoughts??


#6

If this is correct can we check the sight for errors and let me move on??


#7

Can somebody reply to questions???


#8

Please post what you have so far. Thanks,


#9

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);
}
printPerson(contacts[0]);
printPerson(contacts[1]);

#10

the space separator should be only one space, not two.


#11

Thanks, that solved it, after about 11/2 days working on it.


#12

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