JavaScript · Lesson 2 of 4
Count button clicks
let keeps a number you can change. Increase it on each click, then display it. Running the code again starts the counter at zero.
Your task
Change the increase from 1 to 2. Run the code and click three times. What number appears?
Each new lesson builds on your personal page. Your saved lesson draft opens when you return.
The image stays in your browser. Choose it, then use its filename when you add the image to your code.
Edit your project HTML and CSS
Your page
Checks use your current code. Try the page yourself too.
Your feedback
Did you get 6? Restore the increase to 1 and try again, then move on to showing details.
Next: Show detailsI need help
Change the number in clicks + 1; leave clicks = 0. “Run code” resets the counter, while the button in the result increases it.
Save the page to your computer
If the download does not start, copy the complete code below into a text file named index.html and save it as UTF-8.