Team Stats, added loop

Original project link:

Hello All! I passed this project but wanted to add a for loop for more practice, it’s called currentRank() and it’s the last method inside the team object. Everything worked fine otherwise and I get no erros, however if I attempt to console log currentRank, all I get is: returns: [Function: currentRank]. Any suggestions?

const team = {
  _games : [
      {opponent: "France", teamPoints:47, opponentPoints:35},
      {opponent: "Germany", teamPoints:56, opponentPoints:56},
      {opponent: "Austria", teamPoints:57, opponentPoints:43},
      {opponent: "Russia", teamPoints:44, opponentPoints:39}],
  _players :  [
      {firstName: "Tia", lastName: "Toomie", age:35},
      {firstName: "Lynn", lastName: "Davis", age:38},
      {firstName: "Allie", lastName: "Davidson", age:42},
      {firstName: "Shante", lastName: "Buruk", age:34}],

  get players() {return this._players;},
  get games() {return this._games;},

  addTeamMember(firstName, lastName, age) {
    let newTeamMember = {
      firstName: firstName,
      lastName: lastName,
      age: age

  addGame(opponent, teamPoints, opponentPoints) {
    let newGame = {
      opponenet : opponent,
      teamPoints : teamPoints,
      opponentPoints : opponentPoints

currentRank() {
  let usaWins = 0;
  let usaTie = 0;
  let usaLoss = 0;
  for (let i = 0; i <; i++) {
  if (teamPoints === opponentPoints) {usaTie += 1} 
  else if (teamPoints > opponentPoints) {usaWins += 1}
  else {usaLoss += 1}}
  console.log(`USA currently holds ${usaWins} wins, ${usaTie}, and ${usaLoss} losses.`);

team.addTeamMember("Mellisa", "Rettinger", 48);
team.addGame("Hungary", 66, 54);
team.addGame("Australia", 73, 28);

console.log(team.currentRank); /* returns: [Function: currentRank] */

It’s a method. That means you have to invoke it (with parenthesis).
And don’t forget to reference keys within the object with this keyword.

1 Like

Thanks so much! got it!

1 Like