- script.js
JavaScript
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;
}
};
return computer;
};
var myComputer = buildComputer(8, 13, 'i7');
console.log('In the cart ' + myComputer.getDescription() + ' that costs ' + myComputer.getPrice());
Result
Goalscompleted
- Before the
buildComputer
function, create objectprocessorPrice
with properties'i5': 5000
,'i7': 10000
. - After it, create object
displayPrice
with properties13: 5000
,15: 10000
. - Add the
memoryPrice
object with properties8: 3000
,16: 4000
.
Comments