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 | |
|---|---|---|
| 1sayHello(); | AThe brackets are missing, so the function is not called and its code does not run. It should be sayHello(); | |
| 2for (let i = 0; i < 3; i++) { sayHello(); } | BsayHello(); sayHello(); | |
| 3You can call the same function twice to run its code twice | Cfunction sayHello() { console.log('Hi!'); } sayHello(); | |
| 4A function must be declared before it is called, or its declaration must be available when the call runs | DThe call inside the loop has no brackets, so sayHello never runs three times. It should be sayHello(); inside the loop. | |
| 5sayHello; | ECalls the function sayHello, so the code inside it runs once | |
| 6for (let i = 0; i < 3; i++) { sayHello; } | FCalls sayHello three times by placing the call inside a loop |
Complete each line of code by filling in the missing parts.
Shade in the letter of the line that contains an error.
functionName() — Calling a function: write its name followed by brackets, like sayHello(), to run its code. You can call it as many times as you like. Without the brackets, it does not run.function sayHello() { console.log("Hi!"); }
sayHello();function sayHello() { console.log("Hi!"); }
sayHello();sayHello();
function sayHello() { console.log("Hi!"); }function cheer() { console.log("Go!"); }
for (let i = 0; i < 3; i++) cheer();let n = 0;
while (n < 2) { sayHello(); n++; }