Plz someone help me🙏 to understand this object | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

Plz someone help me🙏 to understand this object

You are working on a Contact Manager app. You have created the contact object constructor, which has two arguments, name and number. You need to add a print() method to the object, which will output the contact data to the console in the following format: name: number The given code declares two objects and calls their print() methods. Complete the code by defining the print() method for the objects. function contact(name, number) { this.name = name; this.number = number; } var a = new contact("David", 12345); var b = new contact("Amy", 987654321); a.print(); b.print();

6th Jan 2022, 5:43 AM
Sulaiman B. Sani
Sulaiman B. Sani - avatar
3 Answers
+ 3
Add return statement to the function "contact ()"
6th Jan 2022, 6:16 AM
Chigozie Anyaeji 🇳🇬
Chigozie Anyaeji 🇳🇬 - avatar
+ 3
Or add this.print=()=>{ console.log( this.name +":",this.number); } After the this.number declaration
6th Jan 2022, 6:21 AM
Chigozie Anyaeji 🇳🇬
Chigozie Anyaeji 🇳🇬 - avatar
0
Tanx my man
7th Jan 2022, 9:09 PM
Sulaiman B. Sani
Sulaiman B. Sani - avatar