JAVASCRIPT · ОСНОВЫ · LESSON 07

If not.

if and else · about 12 minutes

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

The program selects

if checks the condition. If true, the code is executed in the first brackets.

const points = 8;
if (points >= 5) {
  console.log("Ура!");
}

✦ There's enough points here.

STEP 2

The other way

else is performed if the false test results.

const points = 2;
if (points >= 5) {
  console.log("Ура!");
} else {
  console.log("Ещё раз");
}

✦ It'll be here again.

IN-CLASS PRACTICE

Type the code yourself

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

const points = 7;
if (points >= 5) {
  console.log("Супер");
} else {
  console.log("Попробуй ещё");
}
Open the editor for class work
HOMEWORK

Solve it yourself

Create const score = 3. If score is at least 5, output «Сдано», otherwise «Тренируйся».

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

Opening up your homework