7.Search for a friend..I'm confused


can someone explain to me in depth about this step? I don't understand it whatsoever.


We are asked to write a function, search that takes one parameter, name and searches through the friends object until it finds a firstName with value matching the search term. We have two objects inside friends, bill and steve. Both have a firstName property in their respective objects.

Recall how the list() function was able to iterate over the primary keys of the friends object? We used for..in to cycle through the keys. Take this one step further. Study the instructions carefully and follow them step by step. There should be enough information for you to complete this task.


i think @mtf has said it all :slight_smile:


i can understand what to do i just can't for the life of me understand WHY it's done that way. it makes no a lick of sense to me . everything until this point i've been okay with but this ? No.


Please post a link to this exercise, and a copy of the code you have so far. Assuming your friends object is correct, you don't need to post that. Just the rest of the code.


i just decided to move on without understanding any of the logic behind it . Maybe i'll learn it eventually


Skipping this lesson is not a good idea. We need the concepts learned going forward. Take a break, go for a walk, etc. just to step away for a moment. Then try again.


I actually took a break earlier and came back but i can't get a grasp on it . hold on a second ill post my code and what i'm confused about


here are my first few questions
1. what is this function even doing exactly? from my understanding its just sorting through all the primary properties of the the 'friends' object. also, let me know if this analogy is correct...Primary properties are to objects what direct children are to css elements??
2.what exactly is the significance of this placeholder? If it can be called anything under the sun, what's the point of it exactly?
3. (what i circled in red) ... what's the point of that parameter in the list function? what's it even doing ?
sorry for the dumb questions but i just really would like to understand all of this .


Primary keys are those at the top level of an object. bill and steve are primary keys, each with an object associated.

Secondary keys are those found inside the primary key objects (just tossing this in).

var list = function (obj) {


obj in the above is a locally defined generic variable that points to the object that is passed in.

prop is short for 'property name', often written as key but any name is valid. It should describe what it holds.

The for..in loop cycles through each member of the object, printing out the name of each key.


I was in the same boat as the OP. Thank you very much for the explanation. I have a much better understanding of this now.


I too am having difficulties with this exercise. Just when I think I get the logic of it, the "result" I'm getting doesn't make any sense. I think I have the same code, but it's finding the wrong person in the list. And the feedback says I've done the exercise correctly. I'm confused.


That is extra output as a result of the tests done by the lesson checker. Your result should be at the top of all that. Ignore the rest.


Thanks- I'll check if there's anything above.


Thanks for the explanation. Makes more sense now.