For this algorithm, you are in charge of ordering food and you plan on ordering a lot of food. The food you’ll buy are:
10 French fries
The cost of each item per category is:
sandwich - $8.00
salad - $7.00
wrap - $6.50
french fries - $1.20
The goal of this function is to output the total cost of your order.
We start out by creating four variables of each of the food categories. The cost times the quantity of each food item is assigned to the variables.
const sandwiches = 4 * 8.00;
const salads = 6 * 7.00;
const wraps = 5 * 6.50;
const frenchFries = 10 * 1.20;
Next, we add up all the food items and assign it to a variable called
let totalPrice = sandwiches + salads + wraps + frenchFries;
The function will output the total which is
118.5. That’s it. Hopefully, you understand what’s going on and how we got to this total.