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

Introduction to JavaScript

Embark on a journey to learn JavaScript, the world's most popular programming language. Understand its textual nature, sequence, and how it makes websites interactive. Get hands-on experience by creating your own JavaScript code, switching from blocks to JavaScript, and programming a Microbit to display your age and react to button presses. Overcome challenges and learn to fix broken code.
Learning Goals Learning Outcomes Teacher Notes

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 - What is JavaScript?

    Just like we have many different languages in the world like English, French, Spanish, Japanese and so on, there are many different programming languages in the world and JavaScript is one of those.

    In fact it's actually the most popular programming language and is used by nearly every website because it is very useful for making websites interactive.

    So far you have learned how to create code used blocks like these:

    basic.showString("Hello!")
    

    JavaScript is a textual programming language which means that we type out the code rather than using blocks. Here is the same code as above but in the JavaScript language:

    basic.showString("Hello!")

    2 - Sequence

    When we run our blocks code, the computer runs the first block in the sequence, then the next, then the next and so on.

    basic.showNumber(1)
    basic.showNumber(2)
    basic.showNumber(3)

    JavaScript does the same thing, it runs the first line of code, then the next line, then the next line and so on.

    basic.showNumber(1)
    basic.showNumber(2)
    basic.showNumber(3)
    

    3 - Try some JavaScript!

    Let's dive in and try write your first piece of JavaScript code. The Makecode Microbit project editor also let's you write your code in JavaScript so we will use that.

    Go to the https://makecode.microbit.org website and create a new project.

    4 - Create code using blocks

    Let's start off by creating some code using the blocks.

    Add the following code to your project.

    basic.showString("Hello!")
    

    5 - Switch to JavaScript

    Click on the JavaScript button at the top to switch your code view from Blocks to JavaScript.

    This will show you your code in JavaScript. Although it looks different, it's actually the same code and does the exact same thing.


    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