๐ Your First Coding
Challenge
We've loaded a simple strategy in the code editor. Your task is to make it smarter by changing the bet amount based on
wins and losses.
๐ฏ Step-by-Step
Instructions:
- Click "Close Tutorial" below to see the
code editor
- Find the comment
// TODO: Make this smarter!
- Change the bet logic to double after losses:
if (won) {
currentBet = 1; // Reset to $1 after win
} else {
currentBet *= 2; // Double after loss
}
- Click the ๐ RUN button to test your
strategy
๐ก Bonus Ideas
(Optional):
- Add a safety check: stop doubling if bet exceeds $100
- Bet a percentage of
currentBalance instead of fixed amounts
- Track win/loss streaks and adjust accordingly
- Return
null if currentBalance drops below $50 (stop-loss)
๐ก Hint: The
won parameter tells you if the last bet won (true/false). Use an
if/else statement to change currentBet differently for
wins vs losses.