Challenge

The full text of this chapter, to read or revisit. To practise, do the exercises.

▶ Do the exercises

Exercise 1 — Comparison Operators Practice

Welcome to the Codémon Training Center! Let's check your Aquachu's stats.

Compare Aquachu's stats: 1. Check if level is greater than or equal to 15 2. Check if hp is strictly equal to 50 3. Check if experience is NOT equal to 0 4. Check if attackPower is less than 30 5. Display all results with labels

Starter code
let level = 18; let hp = 50; let experience = 230; let attackPower = 25; // Compare the stats

Exercise 2 — Codémon Battle Validator

Pyrochu wants to battle! But is it eligible? 🔥

Create a battle validation system: 1. A Codémon can battle if level is at least 10 AND hp is greater than 0 2. A Codémon needs healing if hp is less than 20 OR it's poisoned 3. Check if energy is truthy (it might be 0 or undefined) 4. Invert the isAsleep status to get isAwake 5. Display all validation results with clear labels

Starter code
let level = 15; let hp = 35; let isPoisoned = false; let energy = 0; let isAsleep = true; // Create your battle validator
Back to the course