Chapter 19

Building a Lemonade Stand

While working on your random weather forecaster and your lunch app, you came up with a genius business idea: You could combine the two programs to open a lemonade stand!

As the local weather forecaster for Anytown, you should have an advantage over every other lemonade stand in the area. Here’s how it works: People buy more lemonade when it’s hot out. They’re also more willing to pay more money to buy lemonade when it’s hot out. By setting your lemonade price and deciding how much lemonade to make based on the weather, you can maximize your profit and minimize wasted lemonade.

In this chapter, you learn how to build a lemonade stand game.

image

Playing the Game

Before we get started building the lemonade stand game, let’s try it out and see how it works!

Follow these steps to open and play the game:

  1. Go to our JSFiddle Public Dashboard at http://jsfiddle.net/user/forkids/fiddles.
  2. Find the program titled “Chapter 19 – Lemonade Stand” and open it by clicking the title.

    The game will open and run. You see the Lemonade Stand game, as shown in Figure 19-1.

  3. Take a look at the weather forecasts for the week, in the top part of the Result pane.

    These are the daily weather forecasts that the game will use to help calculate how many glasses of lemonade your stand sells.

  4. Enter a number in the field labeled “How many glasses of lemonade do you want ...

Get JavaScript For Kids For Dummies now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.