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

JavaScript

var diceNumber = 2; var firstCat = { name: 'Muffin', points: 0 }; var secondCat = { name: 'Rudolph', points: 0 }; var firstCatName = 'Muffin'; var firstCatPoints = 0; var secondCatName = 'Rudolph'; var secondCatPoints = 0; var runGame = function (quantity, firstPlayerName, firstPlayerPoints, secondPlayerName, secondPlayerPoints) { firstPlayerPoints += muffin.throwDice(quantity, quantity * 6); secondPlayerPoints += muffin.throwDice(quantity, quantity * 6); console.log(firstPlayerName + ' rolled ' + firstPlayerPoints); console.log(secondPlayerName + ' rolled ' + secondPlayerPoints); }; runGame(diceNumber, firstCatName, firstCatPoints, secondCatName, secondCatPoints);

Thanks! We’ll fix everything at once!

Result

  1. Delete all parameters except quantity in  declaration of runGame function and add new parameters: firstPlayer and secondPlayer.
  2. Delete all arguments except diceNumber in the call of runGame function and add new arguments: firstCat and secondCat.
  3. In the body of the function, replace firstPlayerPoints with firstPlayer.points, firstPlayerName with firstPlayer.name.
  4. Similarly, replace variables with objects for the second player.
  5. Delete variables firstCatName, firstCatPoints, secondCatName, secondCatPoints.