Interactive online courses HTML Academy
2026-03-09 14:09 Diff
  • script.js

JavaScript

var diceNumber = 2; var firstCat = { name: 'Muffin', points: 0 }; var secondCat = { name: 'Rudolph', points: 0 }; var runGame = function (quantity, firstPlayer, secondPlayer) { firstPlayer.points += muffin.throwDice(quantity, quantity * 6); secondPlayer.points += muffin.throwDice(quantity, quantity * 6); console.log(firstPlayer.name + ' rolled ' + firstPlayer.points); console.log(secondPlayer.name + ' rolled ' + secondPlayer.points); }; runGame(diceNumber, firstCat, secondCat);

Thanks! We’ll fix everything at once!

Result

  1. Create an array cats with firstCat, secondCat elements before function runGame.
  2. Delete parameters firstPlayer and secondPlayer in declaration of function runGame and instead of them add parameter players.
  3. Delete arguments firstCat and secondCat in function call and instead of them add argument cats.
  4. In the body of the runGame function, instead of the entire code, write a loop that increases variable i from 0 to players.length (not including this value). Value of i must increase by one after each iteration.
  5. Inside the loop, log in the console the current element of the players array.