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

Level9>lession 8

Couldn't understand how to define method
by

2 Answers

kshitijrana14
Try this one:

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.`);
}
};

// call the method with argument = 2
mobile.purchase(2);
rajnishsinghrajpoot
golang ka level 6 > lession 8 kisi ko ata hai to plz help

Login / Signup to Answer the Question.