Contact List Search For A Friend


var friends = {
bill: {
firstName: "Bill",
lastName: "Bob",
number: "(206) 555-5555",
address: ["One Microsoft Way", "Redmond", "WA", "98052"]
steve: {
firstname: "Steve",
lastName: "Jimmy",
number: "(456) 468-9852",
address: ["Five Apple Way", "Rebmend", "GH", "50916"]
var list = function (friends){
for (var firstName in friends) {
var search = function(name) {
for (var key in friends) {
if (friends[key].firstname === name) {
return friends[key];

it prints

{ firstname: 'Steve',
lastName: 'Jimmy',
number: '(456) 468-9852',
address: [ 'Five Apple Way', 'Rebmend', 'GH', '50916' ] }
{ firstname: 'Steve',
lastName: 'Jimmy',
number: '(456) 468-9852',
address: [ 'Five Apple Way', 'Rebmend', 'GH', '50916' ] }

and I need bill as well can any one help me please?


You need bill? Does bill not exist? Or should bill do something? What are you asking?

Are you talking about what it is printing? That's different from return values.

Your code does not print anything at all. The result of running your code is absolutely no output. You're creating a few functions and then the program is over. They are never called.

The output that's showing up in your console isn't the result of your code.
You can confirm this by adding something like this at the end of your code:

console.log('====== END OF MY OWN OUTPUT ======');


the second bit where the four lines are repeated at the end I need one like that but with bill as well as that is what is printed


Why would it be printed? What in your code would cause that to show up? Which part of the code is responsible for that behaviour, what are you looking to fix? Under what circumstances should bill be printed? What chain of events is supposed to happen but isn't?

See where I'm going here? It's not enough to just "print bill", because the answer to that is to do: console.log(friends.bill)

Again, there's no output at all from your code as it is right now, because you do not invoke any of the functions.


Then how does it print the Steve lines twice when I haven't told it to?


It doesn't. Something else does. Adding a console.log at the very end shows this, as it would be the last thing executed, yet there comes more output afterwards.