I created a contact object and added a print method to it.. the problem is I get an error code saying no input | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

I created a contact object and added a print method to it.. the problem is I get an error code saying no input

This is what the code looks like function contact(name, number) { this.name = name; this.number = number; this.print = function() {this.name = name; this.number = number; console.log(name, number )} } var a = new contact("David", 12345); var b = new contact("Amy", 987654321); a.print(); b.print();

20th Jul 2021, 3:36 PM
Adigwe Leo
Adigwe Leo - avatar
2 Answers
+ 1
Works fine for me
20th Jul 2021, 3:44 PM
Abhay
Abhay - avatar
+ 1
There was silly mistake you done. I fixed it :) function contact(name, number) { this.name = name; this.number = number; this.print = function() {this.name = name; this.number = number; console.log(name+": "+number )} } var a = new contact("David", 12345); var b = new contact("Amy", 987654321); a.print(); b.print();
2nd Oct 2022, 2:54 PM
Pallab Das
Pallab Das - avatar