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 | |
|---|---|---|
| 1nums.filter(function(n) { return n > 2; }) | AWrong - missing the 'return' keyword | |
| 2people.filter(function(p) { return p.age >= 18; }) | BCreates a new array of only the adult people | |
| 3Runs a function on every element to keep matches | Creturn | |
| 4Decides whether an element passes the test | DWrong - 'filter' must start with a lowercase f | |
| 5nums.Filter(function(n) { return n>2; }) | ECreates a new array with only numbers over 2 | |
| 6nums.filter(function(n) { n > 2; }) | Farray.filter(function(item) { ... }) |
Complete each line of code by filling in the missing parts.
Shade in the letter of the line that contains an error.
filter() — Creates a new array containing only the elements that pass a test provided by a function.let big = nums.filter(function(n) {let big = nums.filter(function(n) {return n % 2 === 0;let adults = people.filter(function(p) {let adults = people.filter(function(p) {
return p.age >= 18;
});