Dragon Slayer!
What you'll be building

Now that you know how to use while loops, we'll combine them with some other control flow statements (like if/else) to create a dragon slaying mini game.

In this game, you’ll battle a dragon. It will take 4 hits to slay the dragon, and if you miss even one hit, the dragon will defeat you!


Check out the code in the editor. Do you understand how it works? (No worries if not—we'll go through it step-by-step!)

Run it a few times to see how you fare against the dragon!