Coding a search function for an object. Please, help


#1


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

I keep getting the "SyntaxError: Unexpected end of input" message and I can't seem to figure out why? Thank you in advance for any helps.


var friends = Object();

friends.bill = new Object();
friends.bill.firstName = "Bill";
friends.bill.lastName = "Gates";
friends.bill.number = "1-555-555-5555";
friends.bill.address = ['One Microsoft Way','Redmond','WA','98052'];

friends.steve = new Object();
friends.steve.firstName = "Steve";
friends.steve.lastName = "Jobs";
friends.steve.number = "1-666-666-6666";
friends.steve.address = ['One Microsoft Way','Redmond','WA','98052'];



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

    };
    
var search = function(name) {
  for(var key in friends) {
    if(friends[key].firstName === name) {
      console.log(friends[key]);
      return friends[key];
    };
  };


#2

Remember to close your function body...

var search = function(name) {

};

We do not write a semi-colon after for or if code blocks.

for ... {
    if ... {

    }
}

#3

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