7. list em all


#1

PLEASE HELP

ERROR: look like your search function doesnt return contact info for Steve.

var friends = new Object();
var list = function(friends){
for (var list in friends){
console.log(list);}

friends.bill = {
firstName: 'Bill',
lastName: 'Gates',
number: '555-7564948',
address: ['coronado way','87','sanfran']
};

friends.steve = {
firstName: 'Steve',
lastName: 'Jobs',
number: '888-9837498',
address: ['talegas dr', '34' ,'hochi']
}
};
var search = function(name){
for (var search in friends){
if(friends.bill[firstName] === name){
console.log(friends.bill);
return friends.bill;
}
if(friends.steve[firstName] === name){
console.log(friends.steve);
return friends.steve;
}
}
};
search();


#2

first of all you didnt call yout search function with an property.

search("Steve");

And your search function is wrong.
What would your search function do if we add some more propertys to your friends object?


#3

how can i add more properties to my friends object?


#4

This would add Gerda

friends.gerda= {
    firstName: 'Gerdal',
    lastName: 'Holmes',
    number: '555-3562782',
    address: ['Example way','1337','Newtown']
     };

But this is not what you should do, it`s only a question of mine.
Hardcoding like you do it in your search function is not good


#5

This has got to be one of the most challenging exercises I've encountered yet. The explanation is not very clear at this point. All that is needed is this:

var list = function(obj) {
for(var prop in obj) {
console.log(prop);
}
};

to list the information in the instructions, but I absolutely do not understand how that bit of code translates to what the instructions are asking.


#6

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