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 calculateTotal(price, qty) { | Afunction checkPassword(pass) { | |
| 2function printMenu() { | BA good function name: it starts with the verb calculate and clearly says the function works out a total. | |
| 3Start a function name with a verb so it describes an action | CThe function name has a space in it, so JavaScript sees two separate words. Use calculateTotal instead. | |
| 4Write the function name in camelCase with no spaces, capitalising each new word after the first | DThe name x is not meaningful and has no verb. A better name would be addNumbers. | |
| 5function calculate total(price, qty) { | Efunction getHighScore() { | |
| 6function x(a, b) { | FA good function name: it starts with the verb print and names what is printed, the menu. |
Complete each line of code by filling in the missing parts.
Shade in the letter of the line that contains an error.
calculateTotal — A function name is a camelCase verb phrase that says what the function does, like calculateTotal or printMenu. Start with a verb, make it meaningful and use no spaces.function calculateTotal(a, b) {
return a + b;
}function showScore() { console.log(10); }
showScore();function calculateTotal(a, b) {return a+b;}
let total = calculateTotal(5, 3);function calculateArea(w, h) {return w*h;}
calculateArea(3, 4);function printMenu() { console.log("Hi"); }
printMenu();