6/8 Need help, Synax error


#1

Hello!
I'm stuck on this part and I need help, I dont understand why it doesn't work, I even saw other people in the QnA forum and they had the problem, I copied their code which worked, it still says syntax error for me

This is my code:

var friends = {
bill: {
firstName: "Bill",
lastName: "Gates",
number: "(206) 555-5555",
address: ['One Microsoft Way','Redmond','WA','98052']
},

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


#2

This is your code after automatic beautification:

var friends = {
    bill: {
      firstName: "Bill",
      lastName: "Gates",
      number: "(206) 555-5555",
      address: ['One Microsoft Way', 'Redmond', 'WA', '98052']
    },

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

What you need to do is to close the friends definition before defining list:

var friends = {
  bill: {
    firstName: "Bill",
    lastName: "Gates",
    number: "(206) 555-5555",
    address: ['One Microsoft Way', 'Redmond', 'WA', '98052']
  }
};

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

#4

Alright, thanks for replying it worked. I didnt notice I didnt close it :slight_smile:
Thanks!


#5

You're very welcome! :slight_smile:


#6

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