© Pradeeka Seneviratne  2019
Pradeeka SeneviratneBBC micro:bit Recipeshttps://doi.org/10.1007/978-1-4842-4913-0_10

10. Functions and Arrays

Pradeeka Seneviratne1 
(1)
Udumulla, Mulleriyawa, Sri Lanka
 

First, this chapter presents how to create functions and use them in your code to reduce the coding time and debugging time. It also increases the readability of code and will make your code cleaner and more concise. Then it presents how to create different type of arrays and offer some useful functions that can be applied to arrays such as finding the number of items, replacing items, inserting items, removing items, finding the index of an item, traversing through arrays, and reversing arrays.

10-1. Creating a Function

Problem

You want to convert 12 inches ...

Get BBC micro:bit Recipes: Learn Programming with Microsoft MakeCode Blocks now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.