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 | |
|---|---|---|
| 1/** Adds two numbers together. */ | AA doc comment placed above a function that states what the function does | |
| 2@param {number} price - Cost of one item | B/** @returns {number} The total cost */ | |
| 3A doc comment states what the function returns using the @returns tag | CA tag that names an input to the function, gives its type and says what it is | |
| 4A good comment explains the purpose of the function, not just a repeat of the code | DThe comment just repeats the code in words and does not explain the purpose | |
| 5/* Adds two numbers */ function add(a, b) { return a + b; } | EThe comment starts with /* instead of /**, so it is a normal block comment and not a doc comment | |
| 6// Sets x to x + 1 let x = x + 1; | F// Checks if a student passed (mark 50 or more) |
Complete each line of code by filling in the missing parts.
Shade in the letter of the line that contains an error.
/** ... */ — A doc comment placed above a function. It says what the function does, lists its inputs with @param and its output with @returns, so others can use it without reading the code./** Adds two numbers together. */
function add(a, b) { return a + b; }/**
* @param {number} a - the first number
*//**
* @returns {number} The total of a and b
*/// Checks if a number is even
function isEven(n) { return n % 2 === 0; }/** @param {number} n - number to check */
function isEven(n) { return n % 2 === 0; }