JavaScript Variables

Storing and managing information in your programs

1
2
3
What is a Variable?

📦 Think of Variables as Boxes

A variable is like a labeled box that can store different types of information. You can put something in the box, check what's inside, or replace the contents with something else.

🎯 Why Variables Matter

  • Store information that your program can remember
  • Track changes over time (like a counter)
  • Make your code reusable and flexible
  • Give meaningful names to values

💡 Key Learning Objectives

  • Understand what variables are and why they're important
  • Learn to declare variables with let and constants with const
  • Explore different data types
  • Practice variable naming conventions
Variable Boxes
💬

message

string

"Hello World!"
📅

year

const string

"2024"

🔒 constant

🔢

count

number

"0"
👁️

isVisible

boolean

"true"
🔢 Counter Demo

Click Count

0

Variable: count = 0

Quick Tips
💡Use let for values that will change
🔒Use const for values that stay the same
📝Choose descriptive names that explain what the variable contains
🎯JavaScript is case-sensitive: nameName