7. Search for a friend


#1


https://www.codecademy.com/courses/javascript-beginner-en-3bmfN/0/7?curriculum_id=506324b3a7dffd00020bf661#

Oops, try again. It looks like your search function doesn't return contact information for Steve.
What do I need to do to return this info. correctly?


var friends = {
    
    bill: {
        firstName: "Chiedo",
        lastName: "John",
        number: "(540) 555-5555",
        address: ['177 Silver Lake Rd.', 'Dayton', 'VA']
        },
    steve: {
        firstName: "Steven",
        lastName: "Holsinger",
        number: "(540) 777-7777",
        address: ['207D Weeping Willow Ln.', 'Bridgewater', 'VA']
        }   
};

var list = function (friends) {
    for (var firstName in friends) {
        console.log(firstName);
        }
    };
    
var search = function (name) {
    for (var key in friends) {
        if (friends[key].firstName === name) {
            console.log(friends[key]);
            return friends[key];
        }
    }
};


#2

Problem is in the friends object. Codecademy expects that the firstName of bill will be "Bill" and firstName of steve should be "Steve".


#3

Thanks! I was actually just coming back to say I figured it out!


#4

Glad to hear that :slight_smile: You're welcome!


#5

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