Interactive online courses HTML Academy
2026-03-09 10:47 Diff
  • script.js

JavaScript

var buildComputer = function (memory, display, processor) { var computer = { basicPrice: 5000, processor: processor, display: display, memory: memory, getDescription: function () { return 'computer'; } }; return computer; }; var myComputer = buildComputer(8, 13, 'i7'); console.log('In the cart ' + myComputer.getDescription());

Thanks! We’ll fix everything at once!

Result

  1. Replace the string returned by method getDescription with 'computer with processor ' + computer.processor + ', diagonal ' + computer.display + ', RAM ' + computer.memory.
  2. Add one more method getPrice, which returns computer.basicPrice, to the computer object.
  3. Replace the message to be logged in the console with 'In the cart ' + myComputer.getDescription() + ' costs ' + myComputer.getPrice().