- script.js
JavaScript
var diceNumber = 2;
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);
Result
Goalscompleted
- Before the
runGame
function, add the first player objectfirstCat
. - Add the property with the player’s name: key
name
, value'Muffin'
to objectfirstCat
. - After the
firstCat
object, add thesecondCat
object with the name'Rudolph'
. - Add to each object a property for storing the points: key
points
, value0
.
Comments