Beginner
One hook, two independent counters
Write useCounter(initial, step) that returns { count, increment, reset }. increment adds step; reset goes back to initial.
Use it twice in Scoreboard: apples start at 0 and go up by 1 (button id="apples", text Apples: N); score starts at 10 and goes up by 5 (button id="score", text Score: N). A button id="reset-score" resets only the score.
What Check tests
- It starts at
Apples: 0andScore: 10 - Two apple clicks show
Apples: 2and leave the score alone - A score click adds 5
- Reset score goes back to 10 and keeps the apples
- Both counters come from
useCounter
Stuck? One hint at a time
The solution unlocks after your first Check. Try first: that is where the learning happens.
Runs in your browser. Your code is saved here.
Your page
Press Run to see the page.
Console
Nothing logged yet.