Your files never leave your device
Advertisement

Variables & Data Types

Variables are the building blocks of any programming language. They allow you to store data, update it, and reference it by name throughout your code.

Declaring Variables

In modern JavaScript, you should almost always use let and const. const is for values that won't be reassigned, while let is for values that will change.

Try It Yourself

        

Data Types

JavaScript has several basic data types: Strings (text), Numbers (integers and decimals), Booleans (true/false), Null (intentional absence of value), and Undefined (variable declared but not assigned).

Try It Yourself

        

Practice

Challenge 1: Create a const variable with your favorite color and log it.

Challenge 2: Create a let variable called counter, set it to 1, then update it to 2 and log it.

Related Guides

Sponsored Utility
While You're Here
Sponsored Recommendations
Advertisement