SparkJS Logo
HomeBeginnerLoops & Conditions

🔄 Loops & Conditions

Learn how to make your code repeat actions and make decisions!

⏱️ 3 hours📚 9 sections⭐ Beginner

Your Progress

0 / 9 completed

📚 Lessons

🤔

What are Conditions?

Conditions let your code make decisions! Just like in real life - 'IF it's raining, THEN take an umbrella' - your code can check things and do different actions based on the result.

💻 Code Example:

// Basic if statement
let score = 85;

if (score >= 80) {
  console.log("Great job! You got an A!");
}

// Check player health
let health = 30;

if (health < 50) {
  console.log("Warning: Low health!");
}

💡 Tip: Copy this code and run it in your browser console to see it in action!

📝 Key Points:

  • if statements check conditions
  • Code runs only if condition is true
  • Perfect for decision making