Ram

Lesson 5 of 20

Conditions & Loops

Choose paths and repeat work.

Introduction

Use if, else if and else to choose a path. Use for, while and for...of to repeat work.

break stops a loop and continue skips to the next iteration.

Key insight

Choose paths and repeat work.

Example

for (const score of [45, 82, 67]) {
  console.log(score >= 50 ? "pass" : "try again");
}

This example shows the core conditions & loops idea in a small, runnable program.

Real-world example

Interfaces loop through API results to create cards and tables.

Test yourself

2-question check

1

What is the main idea in Conditions & Loops?

2

Where can conditions & loops be useful?

Ready to check your understanding?

Answer every question, then submit your quiz.

Try it yourself

JavaScript compiler

Runs in your browser. Nothing is sent to a server.

Output appears here

Practice challenge

Print only odd numbers from 1 through 9.

Previous
Next