JAVASCRIPT · ОСНОВЫ · LESSON 11

As long as the condition is

while loop · about 12 minutes

Learning with progressRead the summary for free. To save the work, log in to the account.
STEP 1

Repeat to the border.

while checks the condition before each step. As long as true answers, the code repeats.

let count = 1;
while (count <= 3) {
  console.log(count);
  count++;
}

✦ There will be 1, 2, 3.

STEP 2

Change the meter.

Inside the loop, increase count so that the condition becomes false one day.

count++;

✦ This line adds one.

IN-CLASS PRACTICE

Type the code yourself

Type an example manually. Check the names, brackets and signs.

let count = 1;
while (count <= 3) {
  console.log(count);
  count++;
}
Open the editor for class work
HOMEWORK

Solve it yourself

Start with let count = 1. Using while, output numbers from 1 to 4, changing count within the loop.

The answer is hidden. Use similar examples from the lesson notes.

Opening up your homework