Compare and Convert (Summary)

Congratulations on finishing Compare and Convert! You started with three plain questions about a hiking pack. How heavy is it? Does it weigh at most the limit? How do you show that total so someone can read it? Now you can write JavaScript that answers questions like these, and you built a pack checker on RealJS that does it.

This summary reviews your new skills in the order you learned them. If any point feels shaky, the lesson named next to it is the place to look again.

Try One Quick Check First

Before you read the recap, answer from memory. Your pack total is 8, and the rule says “at most 8 kg.” Does totalKg < 8 or totalKg <= 8 let this pack through? And what do you get if you add a 0.5 kg water bottle to totalKg.toFixed(1) with +?

Language: JavaScript
> const totalKg = 8
undefined
> totalKg < 8
false
> totalKg <= 8
true
> totalKg.toFixed(1) + 0.5
'8.00.5'

Only <= admits a pack right at its limit. toFixed(1) gives back the text '8.0', so + joins 0.5 onto it instead of adding. If either answer surprised you, the matching section below names the lesson to revisit.

Answer Yes-or-No Questions

In True and False as Values, Compare Numbers and Text With Boundaries, and Ask Whether Two Values Are the Same, you learned to write down and calculate yes-or-no answers. You can now:

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.