Totally lost in search for a friend


#1


  1. Search for a friend

    It looks like your search function doesn't return contact information for Steve.

Even if i copy the solution from the hint section, my search function does not work... What am i doing wrong?


var friends = {};
friends.bill = {
    firstName: 'bill',
    lastName: 'lib',
    number: '(123) 456-7890',
    address: ['123 four street','las vegas','NV']
};
friends.steve = {
    firstName: 'steve',
    lastName: 'eve',
    number: '(555) 555-5555',
    address: ['555 five road','las vegas','NV']
};
var list = function(object){
    for(var key in object){
        console.log(key);
    }
}

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

list(friends);
search("Steve");


#2

HI in your object friends

friends.bill = {
    firstName: 'bill',
    lastName: 'lib',
    number: '(123) 456-7890',
    address: ['123 four street','las vegas','NV']
};
friends.steve = {
    firstName: 'steve',
    lastName: 'eve',
    number: '(555) 555-5555',
    address: ['555 five road','las vegas','NV']
};

change the firstName of both steve and bill from "steve" and "bill" to "Steve" and "Bill"


#3

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