In this video, you got a first look at the adventure-pack checker you’ll build in this course, and at the skills you’ll learn along the way.
Key Points
- The pack checker: Your pack holds a tent, a sleeping bag and some food, and each weight arrives as text, such as
"2.5". By the end of the course, your checker turns those weights into a total of5.75kilograms, tells you whether the pack meets an8kilogram limit, which givestrue, and builds the linePack total: 5.75 kgto show. - What you’ll be able to do: Turn numeric text into numbers you can add, compare values to answer yes-or-no questions, and keep numbers for calculating apart from the text you show. Along the way, you’ll spot text that isn’t a number, meet
nullandundefined, and pick the right way to round. - The course project: On RealJS, you’ll build the calculation core of the checker with three small functions.
packTotal()totals the weights,meetsLimit()answers whether the total meets the limit, andshowTotal()builds the text for the screen. Tests check each answer and give you feedback. - What you need: This course builds on Values, Names, and Text, an earlier course in JavaScript Basics. You’ll need variables, arithmetic, strings and template literals, and you’ll run short Node scripts in the terminal.
The Checker’s Answers
For the sample pack, the checker’s three answers are a number, a Boolean and a line of text:
| Tent | Sleeping bag | Food | Total | Meets the 8 kg limit | Display |
|---|---|---|---|---|---|
"2.5" |
"1.25" |
"2" |
5.75 |
true |
Pack total: 5.75 kg |
This course comes with sample code and a cheat sheet. The sample code has every Node REPL example from the lessons, plus a starter and a solution for each exercise. Keep the JavaScript cheat sheet open as a quick reference while you work:
Next up is True and False as Values, where you’ll store your first yes-or-no answers about the pack.