• Theory
  • Theory

Eleventh program: “The house that Muffin built”

While you were working on the online store, Muffin decided to build a house. He began to write a configurator to calculate the area and cost of construction, but he got tired. And the truth is, why write the code yourself if there are developers who can do it for you?

Meow! Finish the configurator for me. I created the house object and assigned several properties to it: rooms (number of rooms), floors (number of floors), material (material for walls), coefficient (the average area of ​​each room).

I also created the materialPrice map where the cost of any possible construction material is recorded.

Add to the object two methods: calculateSquare, which will return the house area, and calculatePrice, which will return the cost of construction.

Calculate area as follows: multiply the number of rooms by the coefficient and the number of floors in the house.

The price of construction is the product of the area and the cost of the material to build the house.

I’m waiting for the result! Maybe I’ll invite you to the housewarming party.

Press Hey boss, here’s your program! to call the Boss. It’ll change the values ​​in the object and find out how much construction will cost. Good luck!

  • index.html
HTML
HTML

You’ve gone to a different page

Click inside the mini-browser to shift the focus onto this window.

100%
Granny Muffin

Easy there, pal!

To access the Objects challenges in the JavaScript programming, you need to sign up and subscribe first.