Question 12-Search for a friend:Oops, try again. Did you create a function called search?


#1

It keeps showing"Oops, try again. Did you create a function called search?"

var friends={
    bill:{
    firstName:'Bill',
    lastName:'Gates',
    number:0451234849,
    address: ['One Microsoft Way','Redmond','WA','98052']
    },
    steve:{
    firstName:'Steve',
    lastName:'Jobs',
    number:'043571631239',
    address: ['One Microsoft Way','Redmond','WA','98052']
    }

};


var list=function(friends){
    for(var haha in friends)
    {console.log(haha)}
}

var search=function(friends){
    for (var haha in friends){
        if(friends[haha].firstName==='Bill'||'Steve'){
             console.log(friends[haha]);
             return friends[haha]
         }
    }
}

Cannot find out the flawT-T


#2

This is your problem. 1. Define a function search that takes a single argument, name. You should use name instead of friends. Second, to console the friend's contact info you need if(friends[haha].firstName=== to equal name


#3

Thanks a lot,dude! It's really helpful!


#4

No problem glad to help! :smiley:


#5

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