7, search for a friend


#1

hello,

can please someone help?

i dont understand why when i use the search("steve") it shows on the consloe bill details as well?

var friends = {};
friends. bill = {

 firstName: "Bill",
 lastName: "Gates",
 number: "23232323232",
 address: ['55 akiva st', 'raanana']

};
friends. steve = {

firstName: "Steve",
lastNmae: "Roni",
number: "432432432",
address: ['33 oxford st','london']

};

var list = function (friends){
for ( var firstName in friends){
console.log (firstName);
}
}
var search = function(name) {
for(var key in friends) {
if(friends[key].firstName === name) {
console.log(friends[key]);
return friends[key];
}
}
};

search("steve");

list();


#2

Your code is not very readable because of the indentation.


To format your code to make it visible:
1. Paste your code.
2. Select all of your code.
3. Do Ctrl + Shift + C (Windows) or CMD + Shift + C (Mac OSX) to format your code.

OR

1. Paste your code in.
2. Insert 3 backticks (`) before and after your code:

```
Code goes here
```

#3

@nesi_tomer,

1

You are search-ing for the firstName
which have a Capitalized associated VALUE like "Steve" or ""Bill"
so change your search into

search("Steve");

2

In some sections of this course, the course-checker Display's data
this you could then identify by placing to EXTRA code-line's:
console.log( "== My End ==" );
console.log( "== All that is displayed now, is the course-checker ==" );