7. Search for a friend -not producing Steve


What am I doing wrong?

var friends = {
bill: {
firstName: "Bill",
lastName: "Gates",
number: "(206) 555-5555",
address: ["One Microsoft Way", 'Redmond', 'WA', '98052']
steve: {
fistName: "Steve",
lastName: "Jobs",
number: "(207) 555-5555",
address: ["Apple New Way",'Rancho','CA', '48576']

var list = function( friends) {
for (var friends in friends) {
console.log (friends);

var search = function (name) {
for (var firstName in friends) {
if (friends[firstName].firstName === name) {
return friends[firstName];



Believe it or not. Your problem is in your first two sections. You have set up your bill and steve sections a little weird. I would suggest doing them this way.

var friends = {}; //has to be closed!
friends.bill = { // use the object constructor instead
firstName: "Bill",
lastName: "Gates",
number: "(555) 555-5555",
address: ['One Microsoft Way','Redmond','WA','98052']};
friends.steve = { // same here use object constructor
firstName: "Steve",
lastName: "Jobs",
number: "(444) 444-4444",
address: ['One Apple Way', 'Bluemond', 'AW', '25089']};

The rest of your code work beautifully! So this simple change should help you pass the lesson. I am sure there is a way to get it correct like your original plan was I just was not able to configure it quite right in that way without syntax errors. Hopefully this helps! If you would like it more like your original code I can keep trying to fix it. Just let me know!


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