Contact List - Search for friends


I was wondering why we are making two functions and using two for in loops for this challenge. Doesn't this make more sense?

var list = function(name){
        for (var foo in friends){
            if(foo === name){


We use two functions because they each have a unique purpose. list() is a simple untilty to list the primary keys of an object (in this case, friends). We are given this function first so we get some practice with

The search() function is a little more elaborate given a more specific purpose, but it builds upon what we learned writing the list() function. Combining the two functions doesn't make a lot of sense given their differences.


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