Interactive online courses HTML Academy
2026-03-09 14:06 Diff
  • 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 computer = { basicPrice: 5000, processor: processor, display: display, memory: memory, getDescription: function () { return 'computer with processor ' + computer.processor + ', diagonal ' + computer.display + ', RAM ' + computer.memory; }, getPrice: function () { return computer.basicPrice + processorPrice[computer.processor] + displayPrice[computer.display] + memoryPrice[computer.memory]; } }; return computer; }; var myComputer = buildComputer(8, 13, 'i7'); console.log('In the cart ' + myComputer.getDescription() + ' that costs ' + myComputer.getPrice());

Thanks! We’ll fix everything at once!

Result

  1. In all methods, replace calls to properties and methods of computer with calls using this.
  2. Inside the buildComputer function, change the name of the object from computer to customComputer and don’t forget to return the object with a new name.