Overview

For this week, the weekly reading will focus on programming a little more JavaScript much like the lab this week. For this, you will need a plain text editor on the computer you wish to use to complete the assignment:

File Download

You will need to download and extract the a ZIP file to work on this weekly assignment. You can download the ZIP here.

The Assignment

Remember the girl scout order form you finished in Lab #2? We are going to take that a step further! If you open cookies.js, you will find single function: displayOrder().

To begin, go ahead and simply add the following line into the displayOrder() function:

showBox("Thin Mints");

Open up the cookies.html page and submit any order. You should see that your program displays a single "box" of Thin Mints.

 

Now, modify your program to show three boxes of Thin Mins:

showBox("Thin Mints");
showBox("Thin Mints");
showBox("Thin Mints");

Once you have done this, re-load your HTML page, submit any order, and you should see three boxes of thin mints appaer when you submit your order.

 

Following the same pattern, we can insert the different cookie names to display the various different cookie types. Try the following code:

showBox("Thin Mints");
showBox("Caramel deLites");
showBox("Peanut Butter");
showBox("Shortbread");

 

Your assignment is simple: use a while loop to display the correct amount of cookies ordered. Your solution will have a total of four while loops: one for each type of cookie. The while loop should run the correct showBox() function based on how many cookies were ordered.

Submission

Click here to submit your assignment! CS 105 (Spring 2014): Introduction to Computing