Contact List


#1

could anyone help me with it

why we used:- return friends[key];


#2

Consider:

var friends = {
    bill: {},
    steve: {}
};

So that,

var key = 'bill';
console.log(friends[key]);
// {}

bill and steve are keys or member names of the friends object. I like to call these primary keys since they are on the top level.

In a loop construct made with a for..in statement it is common to see key used as the iterator variable of the loop. Each iteration points to a different key, using this variable to hold the name.

friends[key]

might at one time be,

friends['bill']

and at another,

friends['steve']

#3

@mtf thanks i got it..

but why return??
when we have already used console to display..friends[key]