Just Started Team Stats and Already I've Got and Error!

The link to the project is Team Stats

I just can’t what I’ve done wrong. I’ve console.logged the first section of code in order to test it every step of the way because it’s so hard doing it at the end when a lot of error messages come up. I also played around with where the console.log was placed but that didn’t make any difference.

const team = {
_players: {
  captain: {
  firstName: 'Pablo',
  lastName: 'Sanchez',
  age: 31
  }
  /*console.log(this._players);*/
}
  console.log(this._players);

The error message is:

/home/ccuser/workspace/learn-javascript-objects-team-stats/app.js:10
console.log(this._players);
^^^^^^^
SyntaxError: Unexpected identifier

Hi Vickyrai,
If you want to log something to the console inside the object, you have to use a method to do so. Like this…

const team = {
_players: {
  captain: {
  firstName: 'Pablo',
  lastName: 'Sanchez',
  age: 31
  }
},
	consoleLogging(){
  console.log(this._players);
  },
};

team.consoleLogging();

Alternatively, you can finish the object and then console.log(team._players) at the end.

Hi @jonrosk089,

Thanks for your reply.

So I changed the code to the following but it’s still bringing up the same error message:

const team = {
_players: {
  captain: {
  firstName: 'Pablo',
  lastName: 'Sanchez',
  age: 31
  }
}
  console.log(team._players);

**/home/ccuser/workspace/learn-javascript-objects-team-stats/app.js:9**
**  console.log(team._players);**
**  ^^^^^^^**

Count the number of wiggly brackets you’re using on the way up and on the way down.

1 Like

That’s what it was. So obvious yet I couldn’t see it. Thank you!!!

2 Likes

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