Reading & walkthrough: not startedGuided practice: not started
Empty: not started. Yellow: in progress. Green: complete. Marking the whole activity complete does not replace your test results. These circles save in this browser for this pilot.
Rob’s comic strip · Function challenges
ORIGINAL WALKTHROUGH · 5:41
Watch with Rob.
Pause whenever you want to try a change. You can return to the lesson at any time.
You are signed in, but video access needs attention. Check your account access. Your saved work is kept.
Video walkthroughs are included with an active Code Zone membership. The written lesson and practice are free.
Choose Load this code into the editor beside an example, then edit and Run code here. Predict what will print before running it. This is an exploration workspace, so there is no pass/fail challenge. Its saved work stays separate from the next practice activity.
Load an example, edit it and run it. Word wrap is enabled.
Your check results
Work in VS Code instead
Copy the starter into a file named practice.js in VS Code. If Node.js is installed, open the terminal in that folder and run node practice.js. Compare the output with the task above. Automated challenge checks are available in the browser editor.
Code example
example.jsjavascript · example
function winner(player1, player2) { if (player1 > player2) return "Player 1 wins!"; if (player2 > player1) return "Player 2 wins!"; return "Draw!";}console.log(winner(6, 2));console.log(winner(1, 5));console.log(winner(3, 3));
Open the code-along notes
Original dice challenge
Create player1 and player2 roll values using a 1–6 random helper. Print both values and say which player wins, or Draw! if they are equal.
Before adding randomness, write winner(player1, player2) and call it with known pairs. This makes each branch easy to inspect. The next practice deliberately starts with a missing draw branch.
Original dice challenge
example.jsjavascript · example
function winner(player1, player2) { if (player1 > player2) return "Player 1 wins!"; if (player2 > player1) return "Player 2 wins!"; return "Draw!";}console.log(winner(6, 2));console.log(winner(1, 5));console.log(winner(3, 3));