Team Stats : weird issue

Hi Guys,

I’m working on the Team Stats lesson and noticed a weird issue. My code below wouldn’t log to the right window (i.e. console.log).

const team = {
  _players: [
  {firstName: 'Pablo', lastName: 'Sanchez', age: 11 },
  {firstName: 'Dingo', lastName: 'Horehaz', age: 11 },
  {firstName: 'Bunja', lastName: 'Gookah',  age: 11 }
  ],
  _games: [
  {opponent: 'Bos', teamPoints: 42, opponentPoints: 27 },
  {opponent: 'Mus', teamPoints: 13, opponentPoints: 63 },
  {opponent: 'Hos', teamPoints: 37, opponentPoints: 19 } 
  ],
	// step 5
  get players(){
    return this._players
  },
  // step 5
  get games(){
    return this._games
  },
} // temp end team object to do some testing
// testing below to ensure arrays can be displayed
console.log(team.players)

I just couldn’t figure out why it wouldn’t work. Completely puzzled, I pasted the above code into the Meal Maker lesson AND IT WORKED! Is that weird or what? Results below.

[ { firstName: 'Pablo', lastName: 'Sanchez', age: 11 },
  { firstName: 'Dingo', lastName: 'Horehaz', age: 11 },
  { firstName: 'Bunja', lastName: 'Gookah', age: 11 } ]

Any thoughts on what I am not understanding correctly?

Thank you.

1 Like

so you copied this code from one freeform project to the other, and then everything worked as expected?

It works fine for me. What window is it logging to ? And are you copy pasting you’re code correctly ?

Here is the code that should work.

<html>
<head>
<style>
</style>
</head>
<body>
<script>
const team = {
  _players: [
  {firstName: 'Pablo', lastName: 'Sanchez', age: 11 },
  {firstName: 'Dingo', lastName: 'Horehaz', age: 11 },
  {firstName: 'Bunja', lastName: 'Gookah',  age: 11 }
  ],
  _games: [
  {opponent: 'Bos', teamPoints: 42, opponentPoints: 27 },
  {opponent: 'Mus', teamPoints: 13, opponentPoints: 63 },
  {opponent: 'Hos', teamPoints: 37, opponentPoints: 19 } 
  ],
	// step 5
  get players(){
    return this._players
  },
  // step 5
  get games(){
    return this._games
  },
} // temp end team object to do some testing
// testing below to ensure arrays can be displayed
console.log(team.players)
</script>
</body>
</html>

I just followed my exact same steps and can no longer reproduce. Very strange. Sorry to have troubled you but, I don’t think it was user error. Maybe a caching issue?

could very well be.