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 | |
|---|---|---|
| 1if (age >= 10 && age <= 15) | A&& is the wrong operator for outside a range. No number is below 0 and above 40 at the same time, so it should be ||. | |
| 2if (score < 0 || score > 100) | BThe second test is missing the variable name. Each side of && must be a full condition, so it should be age <= 15. | |
| 3Use brackets so the OR is checked first, then the result is combined with AND | CRuns when score is outside the range 0 to 100, because either test being true is enough | |
| 4Use ! to check that something is NOT true, together with another test | Dif (age >= 10 && (house === "Red" || house === "Blue")) | |
| 5if (age >= 10 && <= 15) | Eif (score >= 50 && !isAbsent) | |
| 6if (temp < 0 && temp > 40) | FRuns only when age is between 10 and 15 inclusive, because both tests must be true |
Complete each line of code by filling in the missing parts.
Shade in the letter of the line that contains an error.
if (age >= 10 && age <= 15) — A compound condition joins several tests in one if using && (and), the or operator and ! (not). Brackets set the order. Use it for range checks, like age between 10 and 15.let age = 12;
if (age >= 10 && age <= 15) {
console.log("In range");let age = 18;
if (age < 10 || age > 15) {
console.log("Outside");let done = false;
if (!done && score >= 50) {
console.log("Keep going");if (isMember && (age < 10 || age > 15)) {
console.log("Special price");
}let temp = 25;
if (temp >= 20 && temp <= 30) {
console.log("Nice day");