You’ve made it up to this point! 👏 To quickly recap what you’ve learned up until now:

  • JS is a programming language
  • Variables allow us to store all kind of stuff in the computer memory
  • This blog is just great

As promised, this time we’re going to learn about conditions.

I wanna be the very best

Say you’re developing a game. Where you capture virtual monsters and make them fight each other because of one reason or another. Your monsters have levels, representing their strength and experience in combat. A level 1 monster will be weaker than a level 10 monster, and pretty much powerless against a level 99 monster.

Now there’s a special feature in this game where after reaching a certain level, e.g. level 32, your monster will evolve into a stronger form. 💪 How would that translate into code? The level would be a variable, that we would initialize as such:

var level = 1

And then every time our monster gains a level, we could do this:

level++

Side note: doesn’t it feel great to actually understand how parts of your favorite game work behind the scenes? 🤯 As for myself, I remember how awesome it was when I started learning programming and so much stuff started to make sense!

But then how do we check _if _a level has been passed to make our monster evolve? How do we know when the level 32 has been reached? Well that my friends, is the job of the conditions.

#web-development #programming #coding #javascript #learning-to-code

Let’s make a website: the JavaScript adventures — The conditions
1.05 GEEK