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 = []; for (var i = 0; i &lt; players.length; i++) { var currentPlayer = players[i]; console.log(currentPlayer); } return winners; }; cats = runGame(gameRules, cats); console.log(cats); var tops = getWinners(cats); console.log(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 = []; for (var i = 0; i &lt; players.length; i++) { var currentPlayer = players[i]; console.log(currentPlayer); } return winners; }; cats = runGame(gameRules, cats); console.log(cats); var tops = getWinners(cats); console.log(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>Create variable max that contains the first element of the players array in the body of the getWinners function before the loop.</li>
6 <ol><li>Create variable max that contains the first element of the players array in the body of the getWinners function before the loop.</li>
7 <li>Inside the loop, instead of console log, add a check to make sure that the current player has more points than the record holder.</li>
7 <li>Inside the loop, instead of console log, add a check to make sure that the current player has more points than the record holder.</li>
8 <li>If the condition is met, make the current player the champion.</li>
8 <li>If the condition is met, make the current player the champion.</li>
9 <li>Also log in the console 'New record holder: ' + currentPlayer.points.</li>
9 <li>Also log in the console 'New record holder: ' + currentPlayer.points.</li>
10 </ol>
10 </ol>