Week 8: Conditions
JavaScript code typing course. 17 wpm, 92% accuracy.
Conditions let a program check a situation and choose what to do next. In JavaScript you write if followed by a test in parentheses, such as if (score > 50), and then put the code to run inside curly braces. Use else for the other case. This week you combine comparison symbols with colons, which you meet in switch statements, so every symbol feels automatic before you write a full condition.
What you will learn
This week adds one new symbol and reviews three familiar ones. On the US English layout:
:is Shift plus the semicolon key. Press Shift with the opposite pinky and the semicolon key 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.>is Shift plus the period key. Press Shift with the opposite pinky and the period key with your right ring finger.=is the equals key, pressed with your right pinky.
New keywords this week are else, switch and case. if returns with conditions. In a switch statement, a line such as case 1: ends with a colon.
Technique tips
- Have your opposite pinky ready on Shift before you reach for the colon. The colon and the semicolon share one key.
- Pause for a moment before you type
<or>, so you choose the right comparison. - After you type
if, open and close the parentheses first, then write the test inside them. - The code under a condition goes inside curly braces. Match the opening and closing brace as soon as you type them.
- Keep your eyes on the screen while you type the condition, and read it once before moving on.
Lessons
- Learn (10–15 minutes): Watch the keyboard demo for
:,<,>and=, then type each one a few times. - Practice (10–15 minutes): Type
if (score > 50)andcase 1:lines again and again. - Review (10–15 minutes): Take the two-minute test and focus on the symbols inside your conditions.
This week’s goal
Your targets are 17 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 wrong comparison sign sends the program down the wrong path, so get the symbols right before you chase speed.
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.