HTML Diff
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 gameRules = { diceNumber: 2, maxAttempts: 3 }; var firstCat = { name: 'Muffin', points: 0 }; var secondCat = { name: 'Rudolph', points: 0 }; var cats = [firstCat, secondCat]; var runGame = function (rules, players) { for (var currentAttempt = 1; currentAttempt &lt;= rules.maxAttempts; currentAttempt++) { for (var i = 0; i &lt; players.length; i++) { var throwResult = muffin.throwDice(rules.diceNumber, rules.diceNumber * 6); players[i].points += throwResult; console.log(players[i].name + ' rolled ' + players[i].points); } } return players; }; var getWinners = function (players) { var winners = []; var max = players[0]; for (var i = 0; i &lt; players.length; i++) { var currentPlayer = players[i]; if (currentPlayer.points &gt; max.points) { max = currentPlayer; winners = [max]; } else if (currentPlayer.points === max.points) { winners.push(currentPlayer); } } return winners; }; var printWinners = function (players, winners) { if (players.length === winners.length) { console.log('All cats rock!'); return; } var message = 'The winner is '; for (var i = 0; i &lt; winners.length; i++) { message += winners[i].name; } message += ' with the number of points: ' + winners[0].points; console.log(message); }; cats = runGame(gameRules, cats); console.log(cats); var tops = getWinners(cats); console.log(tops); printWinners(cats, tops);</p>
3 <p>var gameRules = { diceNumber: 2, maxAttempts: 3 }; var firstCat = { name: 'Muffin', points: 0 }; var secondCat = { name: 'Rudolph', points: 0 }; var cats = [firstCat, secondCat]; var runGame = function (rules, players) { for (var currentAttempt = 1; currentAttempt &lt;= rules.maxAttempts; currentAttempt++) { for (var i = 0; i &lt; players.length; i++) { var throwResult = muffin.throwDice(rules.diceNumber, rules.diceNumber * 6); players[i].points += throwResult; console.log(players[i].name + ' rolled ' + players[i].points); } } return players; }; var getWinners = function (players) { var winners = []; var max = players[0]; for (var i = 0; i &lt; players.length; i++) { var currentPlayer = players[i]; if (currentPlayer.points &gt; max.points) { max = currentPlayer; winners = [max]; } else if (currentPlayer.points === max.points) { winners.push(currentPlayer); } } return winners; }; var printWinners = function (players, winners) { if (players.length === winners.length) { console.log('All cats rock!'); return; } var message = 'The winner is '; for (var i = 0; i &lt; winners.length; i++) { message += winners[i].name; } message += ' with the number of points: ' + winners[0].points; console.log(message); }; cats = runGame(gameRules, cats); console.log(cats); var tops = getWinners(cats); console.log(tops); printWinners(cats, tops);</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>In the program code, after the secondCat object, add new cat object thirdCat with the name 'Rocky' and points equal to zero.</li>
6 <ol><li>In the program code, after the secondCat object, add new cat object thirdCat with the name 'Rocky' and points equal to zero.</li>
7 <li>Add a new player to the cats array.</li>
7 <li>Add a new player to the cats array.</li>
8 <li>Change the maximum number of attempts in the game to 10, and the number of dice to 5.</li>
8 <li>Change the maximum number of attempts in the game to 10, and the number of dice to 5.</li>
9 <li>Change the number of attempts and dice to 1.</li>
9 <li>Change the number of attempts and dice to 1.</li>
10 </ol>
10 </ol>