HTML Academy
Let’s not forget about the context
Objects28/30
Back to the list of tasks
  • 1. Shall we play?
  • 2. Players, let’s start!
  • 3. My attempt number one
  • 4. Hello, object!
  • 5. Reading from the object
  • 6. Count off!
  • 7. Overriding object properties
  • 8. Passing object by a link
  • 9. My game
  • 10. Giving out the attempts
  • 11. Who is the winner?
  • 12. Announce the entire list, please
  • 13. Looking for a cat with great results
  • 14. No one will hide
  • 15. New conditions
  • 16. Hard to come across
  • 17. Let’s bring it all to light
  • 18. Roll the dice, gentlemen cats!
  • 19. Let’s make adjustments
  • 20. Summary of “Objects”. Part 1
  • 21. Tenth program: “Golden ball”
  • 22. Build it yourself!
  • 23. My first method
  • 24. Implementing methods
  • 25. Object as a dictionary
  • 26. Bracket notation
  • 27. Let’s not forget about the context
  • 28. Store check
  • 29. Summary of “Objects”. Part 2
  • 30. Eleventh program: “The house that Muffin built”
Summary of “Objects”. Part 2
  • Sign up
  • Log in

Loading…
Everything will be ready in few seconds

  • Theory
  • Theory
  • Comments

Store check

The online store is ready! All we have left to do is check how the program will work on another computer. We need to make sure that regardless of the device’s parameters, a message with technical characteristics will be displayed correctly, and the price will also be calculated correctly.

Create another computer with 16 Gb Ram, a 15″ screen and an i5 processor, find out its price and log a list of characteristics.

Comments

  • script.js
JavaScript
var processorPrice = { 'i5': 5000, 'i7': 10000 }; var displayPrice = { 13: 5000, 15: 10000 }; var memoryPrice = { 8: 3000, 16: 4000 }; var buildComputer = function (memory, display, processor) { var customComputer = { basicPrice: 5000, processor: processor, display: display, memory: memory, getDescription: function () { return 'computer with processor ' + this.processor + ', diagonal ' + this.display + ', RAM ' + this.memory; }, getPrice: function () { return this.basicPrice + processorPrice[this.processor] + displayPrice[this.display] + memoryPrice[this.memory]; } }; return customComputer; }; var myComputer = buildComputer(8, 13, 'i7'); console.log('In the cart ' + myComputer.getDescription() + ' that costs ' + myComputer.getPrice());

What didn’t you like in this task?

Thanks! We’ll fix everything at once!

Console

The code has changed, click “Run” or turn autorun on.

Result

Goalscompleted
  1. After logging the message in the console, create variable anotherComputer, which is equal to the result of function buildComputer with arguments 16, 15, 'i5'.
  2. After declaration of variable anotherComputer, log in the console 'In the recycle bin ' + anotherComputer.getDescription() + ' that costs ' + anotherComputer.getPrice().

Cookies ∙ Privacy ∙ License Agreement ∙ About ∙ Contacts ∙ © HTML Academy OÜ, 2019−2025

VISAMastercard

Log in

or

Forgot your password?

Sign up

Sign up

or
Log in

Restore access

Have you forgotten your password or lost access to your profile? Enter your email connected to your profile and we will send you a link to restore access.

Forgot to connect your email to the profile? Email us and we’ll help.