/01. Variables & Data Types

    01. Variables & Data Types

    Explanation

    JavaScript variables are the building blocks of any application, serving as containers for data values. Using `const` is the modern standard for variables that should not be reassigned, providing safety and readability. On the other hand, `let` is used for variables that will change over time, such as counters or mathematical accumulators. Data types like Strings, Numbers, and Booleans define what kind of data the variable stores and how it can be used. Understanding the difference between declaration, initialization, and assignment is crucial for avoiding bugs. Always prefer `const` by default and only switch to `let` when you specifically need to change the value later.

    Example

    const name = 'Dev';
    let count = 0;

    Exercise Task

    Declare a constant 'username' with your name and a let variable 'score' initialized to 0. Log both.
    script.js
    Console

    Click "Run" to execute your code...

    🍪 We Value Your Privacy

    We use cookies to enhance your browsing experience, serve personalized ads or content, and analyze our traffic. By clicking "Accept All", you consent to our use of cookies according to our Privacy Policy.

    Learn More