I'm stuck with this code, please help



Oops, try again. It looks like your search function doesn't return contact information for Steve.

var friends = {
    bill: {
        firstName: "Bill",
        lastName: "jan",
        number: "5415614561",
        address: ["rosenheim","frühlingstr80","plz:83022"]
    steve: {
        firstName: "Steve",
        lastName: "tomas",
        number: "5745454",
        address: ["vogtareuth","83569"]
var list = function(friends) {
    for (var property in friends) {
    var search = function(name){
    for(var firstName in friends){
        if(friends.firstName === name){
            return friends.firstName;


I would suggest having a different variable for your for loop because you would need to call it again in your if statement,

Let's say you write your for loop like this,

for (var key in friends) {

to check for a name in the contact list you would need a conditional statement that looks like this,

 if(friends[key].firstName === name) {

And to return the value of the list friends your return statement would look something like,

return friends[key];


thank you so much for your help.

the code worked but it gives undefined output


To fix that just change your console.log statement to,



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