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!")
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)
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.
Go to the Makecode.com Microbit website using the link below and click on the 'New Project' button underneath the 'My Projects' heading.
https://makecode.microbit.org/
Install the micro:bit app on your iPad or tablet.
Open the app, tap 'Create code' and then create a new project.

Let's start off by creating some code using the blocks.
Add the following code to your project.
basic.showString("Hello!")
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.
Now let's change the JavaScript code. At the moment the code is making the Microbit show the string "Hello!". Change the code so that it shows the string "My age is".
basic.showString("My age is")
Once you have changed the code, run the code in the Microbit simulator and it should show the string "My age is".
So far we have just changed one of the lines of JavaScript code. Now let's try adding a new line of JavaScript code to program the Microbit to show your age.
Add the new line of code to show your age.
basic.showString("My age is")
basic.showNumber(12)
Now when you run your code in the simulator, it will show the string and then show the number of your age.
Javascript can be very picky with the syntax (syntax is the proper use of words and symbols) of your code. Just one misplaced letter and it will refuse to run again. It is quite normal to make lots of mistakes!
Here are some examples of mistakes.
Note that the editor puts a red line under the code that is broken and when the code is fixed the red line goes away.
If you do make a mistake you can use the undo button to undo the last thing that you did.
OK let's try some more Javascript code. This time we will program the A button to make the Microbit show an icon.
Go onto a new line and add the following code to your project.
basic.showString("My age is")
basic.showNumber(12)
input.onButtonPressed(Button.A, function () {
basic.showIcon(IconNames.Confused)
})
This code programs the button A with a new function when it is pressed. The new function will show the confused icon.
Click on the button A in the simulator and the Microbit should show the icon.
You've just taken your first steps into JavaScript, a powerful language that makes websites come alive. You've learned how to switch from blocks to text code, write simple sequences, handle strings and numbers, and even program a button on the Microbit. Remember, making mistakes is part of learning – keep practising and experimenting.
Every lesson in the course is ready to teach like this one. See what else comes with it, and how to order it.