Chapter 5

JavaScript Blocks

In this chapter

check An introduction to programming in the JavaScript Blocks Editor

check ‘Hello, World!’: your first JavaScript Blocks program

check Programs for reading from button inputs, touch inputs, and the temperature, accelerometer, and compass sensors

check Fruit Catcher: a simple game to program and play on your BBC micro:bit

JAVASCRIPT BLOCKS IS a great entry into programming for younger readers and those without previous computing experience. Its visual environment makes it easy to see which parts of a program go together, and by dragging prewritten code blocks from the toolbox, mistakes are far harder to make than in traditional nonvisual programming environments.

In this chapter you’ll be introduced to the JavaScript Blocks Editor, powered by Microsoft MakeCode, and learn to write a series of programs that make the most of the BBC micro:bit’s capabilities. Finally, you’ll be able to make a quick-fire game in which you’re given the task of catching ever-faster falling fruits before they hit the ground.

Introducing the JavaScript Blocks Editor

The JavaScript Blocks ...

Get The Official BBC Micro:bit User Guide now with the O’Reilly learning platform.

O’Reilly members experience live online training, plus books, videos, and digital content from nearly 200 publishers.