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 | |
|---|---|---|
| 1console.assert(add(2, 3) === 5) | AThe arguments are in the wrong order. The condition must come first and the message second. | |
| 2console.assert(isEven(4) === false, "isEven(4) failed") | BA single = assigns a value instead of comparing. The test should use === to compare the actual result with the expected result. | |
| 3Several test cases in a row check one function with different inputs, and each failing test prints its own message | Cconsole.assert(square(3) === 9); | |
| 4Expected versus actual: the function call is the actual result and it is compared with the expected value using === | Dconsole.assert(double(2) === 4, "double(2)"); console.assert(double(0) === 0, "double(0)"); | |
| 5console.assert(add(2, 3) = 5) | ETests that add(2, 3) gives the expected result 5; it stays silent if the test passes and prints an error if it fails | |
| 6console.assert("add(2, 3) failed", add(2, 3) === 5) | FPrints the message "isEven(4) failed" only if isEven(4) does not return false |
Complete each line of code by filling in the missing parts.
Shade in the letter of the line that contains an error.
console.assert(condition, message) — Prints the message only when the condition is false, so a test like console.assert(add(2, 3) === 5) stays silent when the function gives the expected result.console.assert(add(2, 3) === 5);console.assert(add(2, 3) === 5, "2+3");console.assert(add(2, 3) === 5);
console.assert(add(0, 0) === 0);console.assert(double(4) === 8, "double");const actual = add(4, 6);
const expected = 10;
console.assert(actual === expected, "add");