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 area(w, h) { return w * h; } | Afunction total(a, b) { return double(a) + double(b); } | |
| 2function showArea(w, h) { console.log(area(w, h)); } | BA small helper function that does one job: it returns the area of a rectangle. | |
| 3A helper function returns a value, and the calling function uses that value in a calculation. | Cfunction main() { greet(); playGame(); sayBye(); } | |
| 4A main program calls several small functions in order, one job each. | DA function that calls the helper area() inside its body and prints the result. | |
| 5function showArea(w, h) { console.log(area); } | EThe helper area() has no return, so it gives back undefined and showArea prints undefined. | |
| 6function area(w, h) { w * h; } function showArea(w, h) { console.log(area(w, h)); } | FThe helper is named but never called. It needs brackets and arguments: area(w, h). |
Complete each line of code by filling in the missing parts.
Shade in the letter of the line that contains an error.
helper function — A small function that does one job and is called from inside another function, so a big task is built from small, reusable parts.function twice(n) { return n * 2; }
function four(n) { return twice(twice(n)); }function isEven(n) { return n % 2 === 0; }
function show(n) { console.log(isEven(n)); }let name = getName();
let msg = makeGreeting(name);
showMessage(msg);function sumTwice(a, b) {
return twice(a) + twice(b);
}function entry(age) {
if (isAdult(age)) { console.log("In"); }
}