Project: An Adventure-Pack Checker

Your hike is almost here, and the trail guide recommends a pack that weighs no more than a stated limit. In this project, you’ll build the calculation core of a pack checker on RealJS. Given your gear weights as text, it works out the total, says whether the pack meets the limit, and produces a line of display text.

In Print Your Own Journey Report, you converted text once, compared one value against a goal, and formatted numbers only in the output lines. This project uses the same three moves, with tests that check the results for many different packs.

Read the Brief

Your trail app exports three weights in kilograms, one each for the tent, the sleeping bag, and the food. Each weight arrives as valid numeric text, such as "2.5" or "0.75", so you won’t need to guard against values that aren’t numbers. The limit and the total reach your code as numbers.

The checker answers three questions, and each answer is a single value:

  1. How much does the pack weigh? A number, so you can keep calculating with it
  2. Does the pack meet the limit? A Boolean, true or false, indicating whether the pack weighs at most the limit
  3. What should the screen show? Text in the form Pack total: 5.75 kg, with exactly two decimal places

Locked learning resources

Join us and get access to thousands of tutorials and a community of expert JavaScript developers.

Unlock This Lesson

Already a member? Sign-In

Locked learning resources

The full lesson is for members only. Join us and get access to thousands of tutorials and a community of expert JavaScript developers.

Unlock This Lesson

Already a member? Sign-In

Become a Member to join the conversation.