Signup/Sign In
Ask Question
Not satisfied by the Answer? Still looking for a better solution?

Level 9 lesson 8

make purchase the object method
by

1 Answer

sam5epi0l
Hello brian, try this code:


let mobile = {
name: "Apple iPhone 12",
price: 1200,

// defining method
purchase: function(quantity) {
console.log(`Please pay ${(this.price)*quantity} for ${quantity} ${this.name} Mobile phones.`);
}
};

mobile.purchase(2);

Login / Signup to Answer the Question.