Search for a friend error: Search function doesn't display contact info


#1

Exercise 7 of Course 12, I keep pressing save & submit.
The error message is as follows: Oops, try again. It looks like your search function doesn't return contact information for Steve. I have no clue what to do!

var friends = new Object();

friends.bill = {
    firstName: "Bill",
    lastName: "Gates",
    number: "(410) 422-5778",
    address: ['17439 Delaware Dr', 'Newark', 'DE', '19971']
    };
friends.steve = {
    firstName: "Steve",
    lastName: "Jobs",
    number: "(410) 410-4223",
    address: ['2101 Waverly St', 'Palo Alto', 'CA', '94301']
    };
    
var list = function(friends) {
    for (var key in friends) {
        console.log(friends[key]);
    }
};

var search = function(name) {
    for (var foundFriend in friends) {
        if(foundFriend === name) {
            return foundFriend
        } else {
            console.log("404 Error: Name not found.");
        };
    };
};

#2

Right now

is comparing name to all of the objects in friends. Instead of comparing name to an entire object, you need to compare it to the first name property for each object in friends.


#3

So, how would I do that? I am actually rather new to JavaScript and first truly began to learn it about three days ago, and I probably haven't been learning for an hour a day, so I probably haven't been learning much


#4

nevermind, the correct code was in the hint.


#5

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