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.reduce(function(total, n) { return total + n; }, 0) | AMultiplies every number in nums into a single product | |
| 2nums.reduce(function(total, n) { return total * n; }, 1) | BAdds up every number in nums into a single total | |
| 3Combines every element into a single result value | CWrong - 'reduce' must start with a lowercase r | |
| 4Sets the accumulator's value before the loop begins | DWrong - missing the 'return' keyword | |
| 5nums.Reduce(function(t, n) { return t+n; }, 0) | E0 | |
| 6nums.reduce(function(t, n) { t + n; }, 0) | Farray.reduce(function(total, item) { ... }) |
Complete each line of code by filling in the missing parts.
Shade in the letter of the line that contains an error.
reduce() — Combines every element of an array into a single value using an accumulator function.let sum = nums.reduce(function(total, n) {let sum = nums.reduce(function(total, n) {return total + n;let product = nums.reduce
(function(total, n) {let product = nums.reduce(function(total, n)
{
return total * n;
}, 1);