JavaScript workshop · About 10 minutes
Build a score counter.
Follow one small program from the first line to a working scoreboard. Take your time; you can correct every mistake.
- 1 Understand, current step
- 2 Type, upcoming
- 3 Predict, upcoming
- 4 Repair, upcoming
- 5 Play, upcoming
Step 1 of 5 · Meet the two parts of the program.
One function. Every point counts.
let score = 0 stores a number that can change. The function addPoints receives a number named points.
score += points adds those points to the existing score. Calling the function twice keeps both additions. Finally, console.log prints the result.
Prerequisite: you can type letters, numbers and basic symbols. We will explain the JavaScript as we go.
