0 added
0 removed
Original
2026-01-01
Modified
2026-03-09
1
<ul><li>script.js</li>
1
<ul><li>script.js</li>
2
</ul><p>JavaScript</p>
2
</ul><p>JavaScript</p>
3
<p>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); } return players; }; cats = runGame(diceNumber, cats); console.log(cats);</p>
3
<p>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); } return players; }; cats = runGame(diceNumber, cats); console.log(cats);</p>
4
<p>Thanks! We’ll fix everything at once!</p>
4
<p>Thanks! We’ll fix everything at once!</p>
5
<h2>Result</h2>
5
<h2>Result</h2>
6
<ol><li>At the beginning of the code, in front of the player objects, create an object gameRules with properties diceNumber: 2 and maxAttempts: 3 .</li>
6
<ol><li>At the beginning of the code, in front of the player objects, create an object gameRules with properties diceNumber: 2 and maxAttempts: 3 .</li>
7
<li>In runGame function<em>declaration</em>, rename parameter quantity in rules.</li>
7
<li>In runGame function<em>declaration</em>, rename parameter quantity in rules.</li>
8
<li>In runGame function<em>call</em>, replace argument diceNumber with gameRules.</li>
8
<li>In runGame function<em>call</em>, replace argument diceNumber with gameRules.</li>
9
<li>In the body of the runGame function, replace the reference to parameter quantity with accessing property diceNumber of parameter rules.</li>
9
<li>In the body of the runGame function, replace the reference to parameter quantity with accessing property diceNumber of parameter rules.</li>
10
<li>Delete the diceNumber variable.</li>
10
<li>Delete the diceNumber variable.</li>
11
</ol>
11
</ol>