Contact List problem


#1

please help

var friends = {
steve: {firstName:'Steve',
lastName:'Jake',
number:'(123),345,678',
address:['unknown']},

bill: {firstName: 'Bill',
lastName:'Mike',
number:'(365),136,124',
 address:['unknown']}
};
var list = function (friends){
    for(var friends in friends){
    console.log(friends);
    }


};
var search = function(name){
    for (var friends in friends){

        if(friend[key].firstName === Steve){

        console.log(friends[Steve])

        return friends[steve]

        }else{



        console.log(friends[bill])

        return friends[bill]   
          }
          }
};

SyntaxError: Unexpected end of input
thanks in advance


#2

We cannot have an iterator variable with the same name as the object.

friend in friends

will be okay. Repair both instances of this error.


#3

Okay thx now it is showing
this

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


#4

Okay I changed things around and I passed but
I am having trouble understanding
and also why its logging specific parts please explain

var friends = {
steve: {firstName:'Steve',
lastName:'Jake',
number:123,
address:['unknown']},

bill: {firstName: 'Bill',
lastName:'Mike',
number: 365,
 address:['unknown']},
};
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("bill")

I logs to the console

{ firstName: 'Steve', lastName: 'Jake', number: 123, address: [ 'unknown' ] }
{ firstName: 'Steve', lastName: 'Jake', number: 123, address: [ 'unknown' ] }
{ firstName: 'Bill', lastName: 'Mike', number: 365, address: [ 'unknown' ] }
please explain


#5

The additional logging is due to the lesson check begin performed. Nothing to concern over.


#6

Okay thanks for your help


#7

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