Explore the Lab

To start off, you and your team should explore the lab! Enter various quantities of cupcakes in the text box and press "Submit Order". You will notice that a receipt is generated, but the receipt is incomplete. In order to complete the receipt, you will need to do three things:

Part 1: Find the Total Number of Cupcakes

Inside of cupcakeOrder.js, you will find a sumCupcakes function:
var sumCupcakes = function(cupcake1, cupcake2, cupcake3, cupcake4) { }

Before the function is a description of each of the four parameters passed into the function. Specifically, each of the variables cupcake1, cupcake2, cupcake3, and cupcake4 are the quantities of the different types of cupcakes the user placed in their order. To complete this function, the function must return the total number of cupcakes that are part of the order.

Test your code now!

At this point, make sure that you and your team members all have the receipt displaying the correct information for all the code you have completed to this point. Make sure you understand the code you have written so far. The next part will build on the understanding of this first part.

Part 2: Find the Unique Types of Cupcakes

This function is set up identically to the first function, except that you must return the unique types of cupcakes ordered. For example, if the order contains only "Chocolate Mashed Potato" cupcakes, the number of unique cupcake types is only one (1) regardless of how many "Chocolate Mashed Potato" cupcakes are on the order. Likewise, if at least one cupcake is ordered of only three of the four types of cupcakes, this function must return 3.

Hint: Would a conditional be useful? Should you check if the number ordered of each type of cupcake is equal to 0?

Test your code now!

At this point, make sure that you and your team members all have the receipt displaying the correct information for all the code you have completed to this point. Make sure you understand the code you have written so far. The next part will build on the understanding of this first part.

Part 3: Calculate the Total Price of the Cupcake Order

This function is set up identically to the first two function, except that you must return the total cost of the full order of cupcakes. You should return the price as a number. Do not add a dollar sign.

Hint: You may want to create a new variable called price that starts as zero and is added to four times.

Troubleshooting

Internet Explorer has been known to cause problems, so please make sure you are using either Chrome or Firefox.

If something goes wrong, you can use your browser's console to look at the exact error messages. To get there, right click on the order page and select "Inspect Element". You will see a number of windows pop up and one of the tabs (hint: you may need to look under >> ) is named "Console".

Submission

To submit your lab, you must submit your cupcakeOrder.js to the CS 105 website. You should submit ONLY your .js file. You do not need to submit the other files in the folder. Click here to submit the lab!