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 | |
|---|---|---|
| 1function add(a, b) { return a + b; } | AThe call gives only one argument for a function with two parameters, so b is undefined. It should be add(2, 3). | |
| 2add(2, 3) | BThe parameters a and b are not separated by a comma. It should be add(a, b). | |
| 3Order matters: the first argument goes to the first parameter, so swapping arguments can change the result | Cadd(5) // b is undefined | |
| 4If you give too few arguments, the missing parameter is undefined | DDeclares a function with two parameters, a and b, separated by a comma | |
| 5function add(a b) { return a + b; } | Efunction say(name, age) { } say(12, "Ava") | |
| 6add(2) | FCalls add with two arguments: 2 goes to a and 3 goes to b |
Complete each line of code by filling in the missing parts.
Shade in the letter of the line that contains an error.
function add(a, b) { — Separate several parameters with commas. A call like add(2, 3) must give one argument for each, in the same order. A missing argument becomes undefined.function add(a, b) {
return a + b;
}function add(a, b) { return a + b; }console.log(add(2, 3)); // prints 5function sub(a, b) { return a - b; }
console.log(sub(10, 4)); // prints 6function show(a, b) { console.log(b); }
show(5); // prints undefined