Tip: Choose Save as PDF in the print dialog to download. Use A4 paper size.
Shade in the A or B circle for each question.
Draw a line connecting each item on the left to its match on the right.
| Left column | Right column | |
|---|---|---|
| 1if (score > 50) { console.log("Pass"); } | AThe opening brace { sits on the same line as the if. The statement inside the braces is indented, and the closing brace } sits on its own line. | |
| 2for (let i = 0; i < 3; i++) { console.log(i); } | Bfunction greet() { console.log("Hi"); } | |
| 3Curly braces group all the statements that belong to a function, and the body is indented inside them. | CThe braces group the statements that repeat in the loop. Only the indented code inside { } runs each time. | |
| 4Several statements can share one block. Every line inside the braces is indented the same amount. | DThe opening brace is not on the same line as the if, and the statement inside is not indented, so the block is hard to read. | |
| 5if (age >= 13) { console.log("Teen"); | EThe closing brace } is missing. Every opening { needs a matching } on its own line after the block. | |
| 6if (age >= 13) { console.log("Teen"); } | Fwhile (lives > 0) { lives--; console.log(lives); } |
Complete each line of code by filling in the missing parts.
Shade in the letter of the line that contains an error.
{ } — Curly braces group the statements that belong to an if, loop or function. The code inside the braces is indented so you can see which block it belongs to.if (score >= 50) {
console.log("Pass");
}for (let i = 0; i < 3; i++) {
console.log(i);
}function sayHi() {
console.log("Hi!");
}function double(n) {
return n * 2;
}while (lives > 0) {
lives--;
}