Lesson 1 · Unit 01
Values and expressions
Numbers, text, and the order a calculation happens in
What you practise
- Numbers and text,
console.log, arithmetic and its order,%and**, strings in quotes, one statement at a time
Try a question from this lesson
Pick one
This is a whole program: one instruction. What do you think appears on the screen when it runs?
console.log(2 + 3);Correct answer
5
Why
console.log(...) prints what is inside its brackets. The computer works out 2 + 3 first, then prints the result. You will use it constantly: it is how a program shows you what it did.
The ideas
Concept cards are short on purpose. In the app they appear between questions, after you have met the idea.
Concept
Statements
A program is a list of instructions. Each one is called a statement and ends with a semicolon.
The computer runs statements from top to bottom, one at a time. Nothing is skipped and nothing runs twice, unless you say so.
Each console.log prints on a new line. Printed text is called the program's output.
console.log(1);
console.log(2);
console.log(1 + 2);Concept
Operators and brackets
The four basic operators are +, -, * (multiply) and / (divide). Dividing can give a decimal: 7 / 2 is 3.5.
* and / happen before + and -. To change the order, use round brackets: whatever is inside them is worked out first.
Text after // is a comment: a note for people. The computer ignores it.
console.log((2 + 3) * 4); // 20
console.log(7 / 2); // 3.5Concept
Text is a string
Text goes inside double quotes. A piece of text is called a string: a string of characters.
Nothing inside the quotes is calculated. "2 + 3" is just five characters. The quotes mark where the text starts and ends, and they are not printed.
+ between two strings joins them end to end. Spaces count: if you want one, put it inside the quotes.
console.log("Hello");
console.log("2 + 3");
console.log("Hi " + "Ada");9 more exercises in the app
- 4× multiple choice
- 3× type the answer
- 1× fill the blanks
- 1× true or false
Bitpath is an iOS app in development. Join the waitlist and you get one email when it is ready to try.