Javascript is a versatile programming language used for creating dynamic and interactive web content.
Sometimes, you want your code to make choices. That's where if
statements come in!
let temp = 25;
if (temp > 30) {
alert("It's hot!");
} else {
alert("It's not so hot.");
}
Loops let you run the same code multiple times, saving you from rewriting it over and over.
for (let i = 0; i < 5; i++) {
console.log("Counting: " + i);
}
This prints numbers 0 to 4 in the console.
Showing a special welcome if a user is a VIP
Counting down seconds to start a race
Conditionals help your code make decisions; loops help it repeat tasks.