Microbit JavaScript
Intermediate
60 mins
Teacher/Student led
320 points
What you need:
Chromebook/Laptop/PC

JavaScript Data Types

Explore the world of JavaScript data types in this step-by-step lesson. Learn about strings, numbers, booleans, arrays, and objects, and understand how to use them in your code. Discover the concept of undefined variables and how to handle them. Finally, apply your knowledge in practical exercises, creating and manipulating arrays.
Learning Goals Learning Outcomes Teacher Notes Lesson Files

Live Class Feed

This is a live feed of the latest activity by your students on this lesson. It will update in real-time as they work on the lesson.
Load previous activity

    1 - JavaScript Data Types

    JavaScript variables can store many different data types. A "data type" means the type that the data is. For example a person's name is a string data type (text) and their age is a number data type.

    let firstName = "Marcus"    // string
    let lastName = "Jones"      // string
    let age = 17                // number
    
    In programming, text values are called text strings.

    Strings are written inside double or single quotes. Numbers are written without quotes. If you put a number in quotes, it will be treated as a text string.

    let age = "Fifteen" // string
    let age = "15"      // string
    let age = 15        // number
    

    2 - JavaScript Strings

    A string (or a text string) is a series of characters like "Samuel O'Leary". Strings are written with quotes. You can use single or double quotes.

    let country1 = "USA"    // double quotes
    let country2 = 'Japan'  // single quotes

    You can use quotes inside a string, as long as they don't match the quotes surrounding the string.

    let sentence1 = "Dave O'Leary";           // Single quote inside double quotes
    let sentence2 = "He is called 'Dave'";    // Single quotes inside double quotes
    let sentence3 = 'He is called "Dave"';    // Double quotes inside single quotes

    3 - JavaScript Numbers

    In JavaScript numbers can be written with or without decimal points.

    let price = 4.99   // a number variable with a decimal point
    let age = 23    // a number variable with no decimal point

    4 - JavaScript Booleans

    A boolean is a value that is either true or false. JavaScript booleans can only be one of two values, true or false.

    let isWearingHat = true;
    let isRaining = false;

    Booleans are often used to test conditions in conditional statements such as if then conditional statements.

    if (isRaining){
        isWearingHat = true;
    }else{
        isWearingHat = false;
    }

    5 - JavaScript Arrays

    JavaScript arrays are used to store multiple values in a single variable.

    JavaScript arrays are written with square brackets [] and the array items are separated by commas , The following code creates an array called 'team', containing three players.

    let team = ["John", "Sarah", "Kyrie"]

    Unlock the Full Learning Experience

    Get ready to embark on an incredible learning journey! Get access to this lesson and hundreds more in our Digital Skills Curriculum.

    Copyright Notice
    This lesson is copyright of Coding Ireland. Unauthorised use, copying or distribution is not allowed.
    🍪 Our website uses cookies to make your browsing experience better. By using our website you agree to our use of cookies. Learn more