Tip: Choose Save as PDF in the print dialog to download. Use A4 paper size.
This For Loops worksheet is part of the JavaScript Coding without HTML and CSS journey. Print it as a booklet?
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 | |
|---|---|---|
| 1for (let i = 1; i <= 3; i++) { ... } | AWrong - the parts of a for loop use semicolons, not commas | |
| 2for (let j = 5; j > 0; j--) { ... } | Bi++ | |
| 3Sets the loop counter's starting value | CRuns the block 3 times, with i going from 1 to 3 | |
| 4Increases i by 1 after each pass through the loop | Dlet i = 1 | |
| 5for let i = 1; i <= 3; i++ { ... } | ECounts down from 5 to 1, decreasing j each pass | |
| 6for (let i = 1, i <= 3; i++) { ... } | FWrong - the loop header needs parentheses |
Complete each line of code by filling in the missing parts.
Shade in the letter of the line that contains an error.
for — Repeats a block of code a set number of times, using an initializer, condition, and update expression.for (let i = 1; i <= 3; i++) {for (let i = 1; i <= 3; i++) {for (let i = 1; i <= 3; i++) {for (let j = 5; j > 0; j--) {for (let k = 0; k < 4; k++) {