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

JavaScript

var diceNumber = 2; var firstCat = { name: 'Muffin', points: 0 }; var secondCat = { name: 'Rudolph', points: 0 }; var cats = [firstCat, secondCat]; var runGame = function (quantity, players) { for (var i = 0; i < players.length; i++) { var throwResult = muffin.throwDice(quantity, quantity * 6); players[i].points += throwResult; console.log(players[i].name + ' rolled ' + players[i].points); } return players; }; cats = runGame(diceNumber, cats); console.log(cats);

Thanks! We’ll fix everything at once!

Result

  1. At the beginning of the code, in front of the player objects, create an object gameRules with properties diceNumber: 2 and maxAttempts: 3 .
  2. In runGame function declaration, rename parameter quantity in rules.
  3. In runGame function call, replace argument diceNumber with gameRules.
  4. In the body of the runGame function, replace the reference to parameter quantity with accessing property diceNumber of parameter rules.
  5. Delete the diceNumber variable.