About Strings and Characters
A string is a sequence of characters. You are likely to see strings expressed in many different ways in Makecode projects, so this page shows many of the formats you are likely to encounter.
It also introduces how strings can contain data. Because of this, Makecode has many features for manipulating strings. Examples include indexing and built-in blocks.
With or Without a Variable
Strings do not necessarily have to be assigned to variables. For example, here is a string in a serial write block that uses a string as-is:
In many cases, it is better to name a string. If you use a long string more than once, naming it will save considerable code space. For example, instead of two serial write blocks, a string is named once and printed twice:
ASCII Codes
Inside the micro:bit, characters are actually stored as numbers. In the case of the character A, it’s number is 65. The number for the B character is 66. The numbers are called ASCII codes, and are actually the numbers your keyboard sends your computer when you type the A, B, and other keys. Making projects that manipulate ASCII codes is a first step toward encrypting messages for cybersecurity.
You can find the ASCII Table for codes 0 to 127 in the Reference section: