- 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
quantity
in declaration ofrunGame
function and add new parameters:firstPlayer
andsecondPlayer
. - Delete all arguments except
diceNumber
in the call ofrunGame
function and add new arguments:firstCat
andsecondCat
. - In the body of the function, replace
firstPlayerPoints
withfirstPlayer.points
,firstPlayerName
withfirstPlayer.name
. - Similarly, replace variables with objects for the second player.
- Delete variables
firstCatName
,firstCatPoints
,secondCatName
,secondCatPoints
.
Comments