Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Challenge: Working with Object Methods | Objects Fundamentals
course content

Conteúdo do Curso

JavaScript Data Structures

Challenge: Working with Object MethodsChallenge: Working with Object Methods

Task

You're provided with an object representing a car's details. Your task is to create a method within the object that calculates the car's total price. The car's total cost is calculated by adding the base price and the sum of additional options.

  • Inside the calculateTotalPrice method, use the this keyword to access the car's basePrice.
  • Use the this keyword to access the options (leatherSeats, sunroof, and navigationSystem) from the options object.
  • Calculate the total price by adding the base price and the sum of all options.
  • Log the total price as the method's result.

Expected output:

  1. Inside the method, use this.basePrice to access the base price.
  2. Use this.options to access the options object.
  3. You can use the dot notation to access option properties (e.g., this.options.leatherSeats).

Tudo estava claro?

Seção 2. Capítulo 11
course content

Conteúdo do Curso

JavaScript Data Structures

Challenge: Working with Object MethodsChallenge: Working with Object Methods

Task

You're provided with an object representing a car's details. Your task is to create a method within the object that calculates the car's total price. The car's total cost is calculated by adding the base price and the sum of additional options.

  • Inside the calculateTotalPrice method, use the this keyword to access the car's basePrice.
  • Use the this keyword to access the options (leatherSeats, sunroof, and navigationSystem) from the options object.
  • Calculate the total price by adding the base price and the sum of all options.
  • Log the total price as the method's result.

Expected output:

  1. Inside the method, use this.basePrice to access the base price.
  2. Use this.options to access the options object.
  3. You can use the dot notation to access option properties (e.g., this.options.leatherSeats).

Tudo estava claro?

Seção 2. Capítulo 11
some-alt