Interactive online courses HTML Academy
2026-03-09 12:24 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++) { console.log(players[i]); } }; runGame(diceNumber, cats);

Thanks! We’ll fix everything at once!

Result

  1. Inside the loop in the body of the function, remove element console log.
  2. Within the loop, declare variable throwResult, which contains the result of one roll muffin.throwDice(quantity, quantity * 6);.
  3. Increase the number of roll points for the current player players[i].points += throwResult;.
  4. Log in the console the player’s name and the number of their game points players[i].name + ' rolled ' + players[i].points.