- 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);
}
};
runGame(diceNumber, cats);
Result
Goalscompleted
- Log in the console array
cats
immediately before and immediately after calling therunGame
function. - After the loop, return player array
players
from therunGame
function. - Instead of the usual call of
runGame
, record the result of the function’s operation in variablecats
. - Delete the first log of
cats
in the console.
Comments