Search for a friend


#1



https://www.codecademy.com/en/courses/javascript-beginner-en-3bmfN/0/7?curriculum_id=506324b3a7dffd00020bf661


SyntaxError: Unexpected end of input
Oops, try again. There was a problem with your syntax.

var friends = {
    bill: {
        firstName: "Bill",
        lastName: "Ahmed",
        number: 567890,
        address: ['18th Woodrush Glade', 'Livingston', 'West Lothian'], 
        },
    steve:{
        firstName: "Steve", 
        lastName: "Ahmed", 
        number: 678909,
        address: ['67th Aberdeen Place', 'Aberdeen', 'Aberdeenshire'],
        }
        
};

var list = function(friends) {
    for (var bill in friends) {
        console.log( friends[bill].firstName + " " + friends[bill].lastName + ": " + friends[bill].number);
        
    }
    
    for (var steve in friends) {
        console.log(friends[steve].firstName + " " + friends[steve].lastName + ": " + friends[steve].number);
    }
        
        for (var list in friends) {
            console.log(list);
        }
      
    
};
list(friends);

var search = function(name) {
    for(var bill in friends) {
        if(friends[bill].firstName === name) {
            console.log(friends[bill]);
            return friends[bill];
        }else {
            console.log(friends[steve]);
            return friends[steve];
        }
    };
    
    search("Bill");


#2

hi, this code work

var amis = {
bill: {
prenom: "Bill",
nom: "Gates",
numero: "0456-345",
adresse: ['One Microsoft Way']
},
steve:{
prenom: "Steve",
nom:"Jobs",
numero: "12343-3131",
adresse: ['Two Apple Way']
},

};

var lister = function ( amis ) {
for ( var prenom in amis) {
console.log (prenom);
}
}

var recherche = function (pNom) {
for (var prenom in amis) {
if (amis[prenom].prenom === pNom) {
console.log(amis[prenom]);
return amis[prenom];
}
}
}

lister(amis);
recherche("Steve");


#3

Anyway you can translate the code in english? that would be helpful.


#4

Thank you, it works now.