- 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);
Result
Goalscompleted
- Delete all parameters except
quantityin declaration ofrunGamefunction and add new parameters:firstPlayerandsecondPlayer. - Delete all arguments except
diceNumberin the call ofrunGamefunction and add new arguments:firstCatandsecondCat. - In the body of the function, replace
firstPlayerPointswithfirstPlayer.points,firstPlayerNamewithfirstPlayer.name. - Similarly, replace variables with objects for the second player.
- Delete variables
firstCatName,firstCatPoints,secondCatName,secondCatPoints.
Comments