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