Context
Making Decisions in JS
Take a closer look to the interactive map above.
Let's assume that you find yourself in front of a hotel and you want to spend the night there. You have a specific amount of money in your wallet (let's say 50$ for the sake of our example).
You have no idea if this money is enough to get you a fine bed for the night into the hotel. So you decide to go in and ask at the reception desk.
The first thing you want to ask, is the absolutely essential. If your money is enough to get the cheapest room here or not. This is the first question you want to make, because if the answer is negative, then there is no reason to spend more time in the hotel. You need to find another place.
If your money is enough to buy the cheapest room, then you can also explore further for additional info, in order to find out if you have also enough money for something better.
For example, how much does it cost an upgraded room? If you can't afford it, then you stay with the cheapest room. Otherwise you can upgrade to the better and more comfortable room.
Regardless of that, if you can pay the cheapest room, then you can optionally go for a suite. The only prerequisite is that you are a VIP person (and you can pay the cheapest room at least). Then you get an automatic upgrade to one of the four color suites of the hotel.
Depending on your favorite color you get either the red, blue or green suite.
If none of these is your favorite color then you get the Grey suite.
Although this is a real world problem, we can implement solutions on problems like that in programming, by making decisions. Decisions as we would make them in real life. What we actually did, is that we made comparisons. We compared our money with several prices. Based on the outcome of these comparisons, we made different decisions.
Let's learn how to implement solutions for such problems by writing code!