Exercise 3: How much is the Bill?

In this exercise, you will be required to add a function, totalBill, as a property in the object and implement it as well.

We'll cover the following

In the first exercise, you created an object named product with certain properties defined. This exercise is a continuation of it.

Problem Statement

In this exercise, you are required to write a function totalBill that returns the total bill after the customer buys that product.

Note: Assume all prices are in dollars.

The object from the previous exercise is already given below however the property values are not set. You can set them to whatever you want. The skeleton of the function is already given you just need to write its implementation.

Sample Input

  • name: Cheese

  • price: 20

  • amount: 10

  • madeIn: USA

Sample Output

totalBill returns 200 dollars.

Note: Solution to this exercise is available in the code widget below. However, it’ll be a good practice to solve this problem yourself first. Goodluck!

Create a free account to access the full course.

By signing up, you agree to Educative's Terms of Service and Privacy Policy