Week 9: Loops
JavaScript code typing course. 18 wpm, 92% accuracy.
Loops repeat a piece of code several times without copying it. The most common loop in JavaScript is for, and a line such as for (let i = 0; i < 3; i++) runs the block below it three times. The parentheses hold three parts separated by semicolons, and each part uses symbols you have typed before, plus the semicolon you meet this week. You also meet while, which repeats as long as its condition stays true. Accuracy matters here, because one wrong character can change how many times a loop runs.
What you will learn
This week introduces the semicolon and reviews three symbols. On the US English layout:
;is the semicolon key, pressed with your right pinky.+is Shift plus the = key. Press Shift with the opposite pinky and the = key with your right pinky.=is the equals key, pressed with your right pinky.<is Shift plus the comma key. Press Shift with the opposite pinky and the comma key with your right middle finger.
The new keyword this week is while. In i++, the two plus signs add one to the value of i.
Technique tips
- In a
forline, count the two semicolons before you move on. They separate the three parts. - Type
i++as two plus signs in a row, keeping the rhythm even. - Keep your right pinky ready for the semicolon key, and move only that finger.
- Keep your wrist steady when you type
<in a condition. - Read the loop line once before typing, so you know where it stops.
Lessons
- Learn (10–15 minutes): Watch the keyboard demo for
;,+,=and<, then type each one a few times. - Practice (10–15 minutes): Type
for (let i = 0; i < 3; i++)and shortwhilelines again and again. - Review (10–15 minutes): Take the two-minute test and focus on writing every loop line completely.
This week’s goal
Your targets are 18 WPM and 92% accuracy. Finishing the week earns one star. Reaching 92% accuracy earns two stars, and reaching the speed target as well earns three. A missing semicolon stops a loop line from working, so write each line correctly before you speed up.
Symbols this week
The colored keys are the ones you learn this week. The color shows which finger presses the key.
This week’s lessons
Do the lessons in order. Each one ends with a test, and your best result is saved.