- 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());
Result
Goalscompleted
- Replace the string returned by method getDescriptionwith'computer with processor ' + computer.processor + ', diagonal ' + computer.display + ', RAM ' + computer.memory.
- Add one more method getPrice, which returnscomputer.basicPrice, to thecomputerobject.
- Replace the message to be logged in the console with 'In the cart ' + myComputer.getDescription() + ' costs ' + myComputer.getPrice().
Comments