Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Вивчайте Why Programs Need Decisions and Repetition | Understanding Program Flow and Decisions
Conditional Statements and Loops in JavaScript

bookWhy Programs Need Decisions and Repetition

Imagine you are deciding what to wear in the morning. If it is raining, you choose a raincoat. If it is sunny, pick a T-shirt. This decision is based on the weather. After making your choice, you might brush your teeth, eat breakfast, and pack your bag, actions you repeat every day. Programs work similarly. They make decisions and repeat actions, allowing them to solve problems and handle many situations automatically.

12345678910
// Making a decision with if let weather = "rainy"; if (weather === "rainy") { console.log("Take an umbrella!"); } // Repeating an action with a for loop for (let day = 1; day <= 3; day++) { console.log("Brush your teeth. Day: " + day); }
copy

The code above shows how a computer can make a choice—telling you to take an umbrella if it is rainy—and how it can repeat an action, such as reminding you to brush your teeth for three days in a row. This mirrors the way you make decisions and follow routines in your daily life.

question mark

Which part of the code makes a decision, and which part repeats an action?

Select the correct answer

Все було зрозуміло?

Як ми можемо покращити це?

Дякуємо за ваш відгук!

Секція 1. Розділ 1

Запитати АІ

expand

Запитати АІ

ChatGPT

Запитайте про що завгодно або спробуйте одне із запропонованих запитань, щоб почати наш чат

Suggested prompts:

Can you explain how the if statement works in this example?

What does the for loop do in the code?

Can you give more examples of decisions and repetitions in programming?

Awesome!

Completion rate improved to 7.69

bookWhy Programs Need Decisions and Repetition

Свайпніть щоб показати меню

Imagine you are deciding what to wear in the morning. If it is raining, you choose a raincoat. If it is sunny, pick a T-shirt. This decision is based on the weather. After making your choice, you might brush your teeth, eat breakfast, and pack your bag, actions you repeat every day. Programs work similarly. They make decisions and repeat actions, allowing them to solve problems and handle many situations automatically.

12345678910
// Making a decision with if let weather = "rainy"; if (weather === "rainy") { console.log("Take an umbrella!"); } // Repeating an action with a for loop for (let day = 1; day <= 3; day++) { console.log("Brush your teeth. Day: " + day); }
copy

The code above shows how a computer can make a choice—telling you to take an umbrella if it is rainy—and how it can repeat an action, such as reminding you to brush your teeth for three days in a row. This mirrors the way you make decisions and follow routines in your daily life.

question mark

Which part of the code makes a decision, and which part repeats an action?

Select the correct answer

Все було зрозуміло?

Як ми можемо покращити це?

Дякуємо за ваш відгук!

Секція 1. Розділ 1
some-alt