+ 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
4 Respostas
+ 5
https://code.sololearn.com/Wozr9Ygl3i9T/?ref=app
Check this
+ 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);
0
Thanks for the advise 😀
- 2
Anirudh Thank you so much for the help 😇