7. Search for a friend


var friends = new Object();
friends.steve = new Object();
friends.bill = new Object();

friends.bill.firstName = "Bill"
friends.bill.lastName = "A"
friends.bill.number = 123

friends.steve.firstName = "Steve"
friends.steve.lastName = "B"
friends.steve.number = 456

var search = function (name) {
for (var name =
if (name === friends.firstName) {
console.log (friends.name);
return friends.name

I'm not sure what I should do here.
The hint uses "for (var key in object)" which was NEVER explained and I do not want to use something that I don't understand, especially that it doesn't make too much sense right now and completely opposes all the rules of "for" loop told us before -> for (var x = start; x < end; x++)


That will iterate through object and assign each value one at a time as the loop goes into key.

That for makes sense when you just want to loop through something but the index for any given element doesn't matter.


If so, I would highly suggest creators of this course to rewrite it completely. "Hint" section for me is a place to look up things when you have no idea how to use something you already know, not a place to find completely unclear solutions. I try not to use Hints, because I treat those problems like a challenge and this exercise de facto makes you use it no matter what. What's more it makes you use something that wasn't explained before, unmentioned and one has no chance to know already. It makes it all even more uneven in terms of difficulty. Some hints explain that you need to use " to write strings and as we can see some gives you a divine revelation.


Mmh well, that might be difficult to make happen.

There are plenty of challenges to be had with programming, but I suggest not limiting your intake of information! :slightly_smiling: Definitely don't hesitate to google things, the more the better really.

It would of course be bad to just use things without understanding them, so the thing to google for is understanding, not code that can be used.

And with the help of google and other resources you'll be better able to take on greater challenges!
For example: