Contact Manager unsolved help me to solve it!! | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

Contact Manager unsolved help me to solve it!!

I've already applied all tactics what I have knowledge js but still unable to figure out the output would you please help me? Thank you . The code is as follows:: function contact(name, number) { this.name = name; this.number = number; } var a = new contact("David", 12345); var b = new contact("Amy", 987654321); function newContact(name, number); a.print("name: " + a.name + "number: " + a.number); console.log(a.print()); b.print("name: " + b.name + "number: " + b.number); console.log(b.print());

25th Nov 2022, 9:25 AM
Sony
Sony - avatar
4 Answers
+ 3
Sony Hossain make print function not newContact function. And also no need to print extra things just print values inside print function this.print = function() { console.log(this.name + ': ' + this.number; } now just call a.print() b.print()
25th Nov 2022, 5:33 PM
A͢J
A͢J - avatar
+ 3
Sony Hossain You have to create print function inside given function 'contact' Making new function 'newContact' doesn't make any sense. Read the lesson again and try to solve
25th Nov 2022, 10:41 AM
A͢J
A͢J - avatar
+ 1
Actual Code is:. function contact(name, number) { this.name = name; this.number = number; this.print = function(){ console.log("Name: " + this.name + ", " + " Number: " + this.number); } } var a = new contact("David", 12345); var b = new contact("Amy", 987654321); a.print(); b.print(); Thank you so much....
26th Nov 2022, 6:04 AM
Sony
Sony - avatar
0
function contact(name, number) { this.name = name; this.number = number; this.newContact = function(contact){ this.print() = print(name, number); } } var a = new contact("David", 12345); var b = new contact("Amy", 987654321); a.print("Name: " + a.name + "Number: " + a.number); console.log(a.print()); b.print("Name: " + b.name + "Number: " + b.number); console.log(b.print());
25th Nov 2022, 1:32 PM
Sony
Sony - avatar