🧪 Concept:
An if statement lets your code make decisions. It checks whether something is true — and if it is, it runs some code.
let isRaining = true;
if (isRaining) {
console.log("Take an umbrella!");
}The code inside the { } only runs if the condition is true.
🧰 Why It Matters:
Conditional logic is everywhere — websites, apps, games. It lets your program respond to what’s happening.
🎉 Quick Challenge:
Write a basic if statement that checks your favourite colour:
let favoriteColor = "green";
if (favoriteColor === "green") {
console.log("Nice choice!");
}🧠 Fun Analogy:
Think of an if statement like a gate: “If this is true, open up and let the code through.”
📚 Further Reading:
▪ MDN Docs – if…else
▪ W3Schools – JavaScript If Else
Join us tomorrow for Day 7!
Subscribe to my feed to follow along. I’ll keep the lessons short and sweet.
Leave a Reply