0

Objects topic code project, JavaScript intermediate

Here it goes: I am designing a contact manager, the object constructor function is given with the property parameters given, but I am to add a code for a print() method that outputs on the console the given contact information, in the form of name: number, please, how do I go about it Here is the code: 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();

15th Feb 2024, 1:57 PM
Chinonso Okorie
4 odpowiedzi
+ 2
in the definition of contacts, you need to add a new method called print() show your code attempt if you need help
15th Feb 2024, 2:26 PM
Lisa
Lisa - avatar
0
My code attempt for the print method: this.print = function (print) { console.log(name: + number) };
15th Feb 2024, 6:26 PM
Chinonso Okorie
0
the method should NOT take any argument. it should output this.name and this.number. mind the ":" and the blank space
15th Feb 2024, 6:35 PM
Lisa
Lisa - avatar
0
Chinonso Okorie function is lowercase in javascript. function contact not Function contact just put your this.print definition inside your function body.
17th Feb 2024, 7:11 AM
Bob_Li
Bob_Li - avatar