Interactive online courses HTML Academy
2026-03-09 12:56 Diff

Appetite comes with eating. The boss accidentally noticed a program that counts the number of points scored before the first miss. Now he sends you greetings and a new task along with them: a driver for a dart machine game.

Machine rules:

  • Each game starts with 0 points.
  • You need to collect 100 or more points to win.
  • In the game, you can make no more than three misses, otherwise you will lose.

When writing the program, we’ll use the cycle while, as well as the operators break and continue.

Sometimes programmers create endless loops by mistake after having incorrectly written the stop condition. Such loops can make the browser window in which they are executed “hang”. But if you use endless loops wisely, they can be useful.

We’ll create a loop within which points will be counted using while. Inside the stop condition, we need to check each time if the player scored the required number of points.

In the first step, let’s change the condition so that the game ends when you reach 100 points.