Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Oppiskele The if Statement | Understanding Program Flow and Decisions
Conditional Statements and Loops in JavaScript

bookThe if Statement

Imagine you are leaving your house and you look outside to check the weather. If it is raining, you decide to bring an umbrella; if it is not, you leave the umbrella at home. This everyday decision is just like how your code can make choices using an if statement. The if statement lets your program check a condition and then decide what to do next, just as you decide what to do depending on the weather.

12345
let isRaining = true; if (isRaining) { console.log("It's raining. Bring an umbrella!"); }
copy
question mark

Which of the following conditions should you use inside an if statement to check if a variable named isSunny is true?

Select the correct answer

Oliko kaikki selvää?

Miten voimme parantaa sitä?

Kiitos palautteestasi!

Osio 1. Luku 3

Kysy tekoälyä

expand

Kysy tekoälyä

ChatGPT

Kysy mitä tahansa tai kokeile jotakin ehdotetuista kysymyksistä aloittaaksesi keskustelumme

Awesome!

Completion rate improved to 7.69

bookThe if Statement

Pyyhkäise näyttääksesi valikon

Imagine you are leaving your house and you look outside to check the weather. If it is raining, you decide to bring an umbrella; if it is not, you leave the umbrella at home. This everyday decision is just like how your code can make choices using an if statement. The if statement lets your program check a condition and then decide what to do next, just as you decide what to do depending on the weather.

12345
let isRaining = true; if (isRaining) { console.log("It's raining. Bring an umbrella!"); }
copy
question mark

Which of the following conditions should you use inside an if statement to check if a variable named isSunny is true?

Select the correct answer

Oliko kaikki selvää?

Miten voimme parantaa sitä?

Kiitos palautteestasi!

Osio 1. Luku 3
some-alt