JavaScript Basics
Lesson Progress0%
Topics
Variables and Constants
Topic Overview
Take your time to understand each concept. Practice with the examples below!
Think of variables as labeled boxes where you can store information. Just like you might label a box "toys" or "books", you can create variables with names that describe what they contain.
JavaScript provides three ways to create these storage boxes:
- •let - Use this when the value might change later
Example: let age = 25; (age will change every year)
- •const - Use this when the value should never change
Example: const birthYear = 1998; (birth year never changes)
- •var - This is the old way, avoid using it
Why do we need variables? Variables let us save information to use later in our program. Without them, we'd have to type the same values over and over again!
Ready to practice? Try the exercise below to reinforce your learning!
Try it yourself
Declare a variable called "age" and assign it the value 25. Then create a constant called "name" with your name.
Loading...
1 / 4