+ 1

Contact Manager Challenge In JS

Hi, I'm learning JS but I got stuck in the Contact Manager Challenge because I'm not able to solve it. So this was my attempt but still showing a error: function contact(name, number) { this.name = name; this.number = number; } function print() { var name = this.name; var num = this.number; console.log(name + ":" + " " + number); } var a = new contact("David", 12345); var b = new contact("Amy", 987654321) ; a.print(); b.print(); I don't know why it's showing wrong. So, can anybody help me out in solving? https://code.sololearn.com/WOp89EzYmYA4/?ref=app

18th Dec 2020, 11:13 AM
Programmer
Programmer - avatar
4 Answers
+ 5
https://code.sololearn.com/Wozr9Ygl3i9T/?ref=app Check this
18th Dec 2020, 12:19 PM
Anirudh
Anirudh - avatar
+ 2
Try it function contact(name, number) { this.name = name; this.number = number; this.print = function (name,number){ console.log(name,number); } } var a = new contact("David", 12345); var b = new contact("Amy", 987654321); a.print(a.name+':',a.number); b.print(b.name+':',b.number);
29th Jan 2021, 2:13 AM
Piriyanka Selvarajah
Piriyanka Selvarajah - avatar
0
Thanks for the advise 😀
3rd Feb 2021, 2:45 AM
Programmer
Programmer - avatar
- 2
Anirudh Thank you so much for the help 😇
19th Dec 2020, 5:52 AM
Programmer
Programmer - avatar