Week 10: Functions
JavaScript code typing course. 19 wpm, 93% accuracy.
Functions let you define a piece of work once and run it whenever you need it. In JavaScript you start a definition with the function keyword, then give the name, the parentheses and the parameters inside them. Parameters are separated by commas, as in function add(a, b), which defines a function with two parameters. This week you practice writing both the definition line and the calls, so the parentheses and commas become automatic.
What you will learn
This week introduces one new symbol and uses two you already know. On the US English layout:
,is the comma key, pressed with your right middle finger.(is Shift plus the 9 key. Press Shift with the opposite pinky and the 9 key with your right ring finger.)is Shift plus the 0 key. Press Shift with the opposite pinky and the 0 key with your right pinky.
The new keyword this week is function. Once you can define a function, you can call it with values, such as add(1, 2).
Technique tips
- Type
function add(first, then add the parameters. This keeps the definition line easy to follow. - Put a space after each comma, as in
a, b, so the parameters are easy to read. - Keep your right middle finger ready for the comma, and move only that finger.
- Check that the parentheses close on the same line as the definition.
- Keep parameter names short and clear, and type each one once before you move on.
Lessons
- Learn (10–15 minutes): Watch the keyboard demo for
,,(and), then type each symbol a few times. - Practice (10–15 minutes): Type
function add(a, b)definitions andadd(1, 2)calls again and again. - Review (10–15 minutes): Take the two-minute test and focus on closing every parenthesis.
This week’s goal
Your targets are 19 WPM and 93% accuracy. Finishing the week earns one star. Reaching 93% accuracy earns two stars, and reaching the speed target as well earns three. A function line holds several symbols close together, so accuracy keeps the line working. Speed follows as the pattern becomes familiar.
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.