What is the friggin point of this?!?!?!?!


#1


var list = function(friends){
for(var key in friends){}
};
Why do we need this code? why was it included? I do not understand what it does. When I remove it the code works exactly the same. why is it here?


var friends = {
bill: {
    firstName: "Bill",
    lastName: "Gates",
    number:"1",
    address: [123, 'place1', 'location1']
},
steve: {
    firstName:"Steve",
    lastName:"Jobs",
    number:"8",
    address: [456, 'place2', 'location2']
    }
    };
    var list = function(friends){
        for(var key in friends){}
    };
    var search = function(name){
        for(var key in friends){
            if(friends[key].firstName === name){
                console.log(friends[key]);
                return friends[key];
            }
        }
    };
    search("Bill")


#2

That is a loop that looks at each item in friends but does nothing else. Normally you would have more code there.

var list = function(friends) {        
     for(var key in friends) {
         // in here is where you put code to do something
     }    
};

Which exercise is it that you are working on? If you include a link to it then I can have a look.


#3

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