In this course, you’ll go from filling in functions that earlier exercises handed you to writing, calling, and combining your own.
Your project is an arcade score toolkit. Ada played a round at the shooting gallery: she hit 14 targets and missed 2. When you run the finished scratch/arcade.js with node, it prints her result, and the same code makes the lines for Sam and Leo:
Ada: 130 points (Pro)
Sam: 250 points (Legend)
Leo: 0 points (Rookie)
By the end of the course, you’ll write every function in that file yourself. The toolkit is built from three functions:
roundScore()works out a round’s score from hits and misses: 10 points a hit, 5 off a miss, and never below 0.rankFor()picks a rank for a score: Rookie, Pro, or Legend.scoreMessage()puts the name, score, and rank into a message likeAda: 130 points (Pro).
You’ll build the toolkit in an exercise on the site, where tests try many rounds and players. Then you’ll run a copy on your computer and change a rule.
Along the way, you’ll learn to:
- Write small functions that take values and hand back an answer
- Decide which values stay inside a function
- Combine functions into one program that does all its printing in one place
Before you start, you should be able to run a script with node from the VS Code terminal, store values in variables, and make decisions with if and else blocks. You’ll read lessons, watch a video, practice in exercises with automatic feedback, and run small files of your own.
This course comes with sample code and a cheat sheet. The sample code has the files you’ll create in the lessons, plus a starter and a solution for each exercise. Keep the JavaScript cheat sheet open as a quick reference while you work:
First up is Write and Call Your Own Functions, where you’ll write your first function and put it to work.