Welcome! This is the homework to accompany Girl Develop It LA's JavaScript 201: Intermediate JavaScript class. You can always reference the slides if you get stuck. Commit to spending at least 20 minutes trying to figure out a problem before you peek at the answer. It helps you learn!

Froyo Machine

Your task is to create a froyo machine! Go through these steps:

  1. Download and unzip froyostarter.zip. Open in your favorite text editor and in the browser.
  2. In index.html, we have given you a power button, and three flavor buttons on the machine. When the user presses the power button, the click event will fire for that element. We have started writing a callback function for you. Find the togglePower() callback function.
  3. Inside the togglePower() callback, bind an event listener to each flavor button on the machine that listens for the click event.
  4. Next, set isOn to true inside of the same callback function.
  5. Each button on the machine should do something. Use the included froyo images: img/chocolate.jpg, img/strawberry.jpg, and img/vanilla.jpg to create an <img> tag, add an src attribute, and append it to the dispenser inside the machine.
  6. In the browser, check that you can turn the machine on, and that your images get appended to the dispenser as expected.
  7. Now, we also want to be able to turn the machine off. Add logic so that events are bound to the flavor buttons when the machine turns on and are unbound when the machine turns off. We don't want the flavor button to do anything if the machine is off. Also make sure that the isOn variable is changing to accurately reflect the state of the machine.

Bonuses

Do all or as many as you can.

Hints