- 1

Can someone please help me, I've tried. Where's my mistake?

function contact(name, number) { this.name = name; this.number = number; this.print= print; } var a = new contact("David", 12345); var b = new contact("Amy", 987654321); console.log(a.print( return this.name: this.number)); console.log(b.print( return this.name: this.number ));

28th May 2021, 1:50 PM
Nmelichukwu Ubosi
Nmelichukwu Ubosi - avatar
3 Réponses
+ 1
function contact(name, number) { this.name = name; this.number = number; } contact.print = function() { console.log(this.name+" "+this.number); }; var a = new contact("David", 12345); var b = new contact("Amy", 987654321); a.print(); b.print();
28th May 2021, 7:58 PM
visph
visph - avatar
0
Can someone please help me, I've tried. Where's my mistake? function contact(name, number) { this.name = name; this.number = number; this.print= this.name+this.number.toString(); } var a = new contact("David", 12345); var b = new contact("Amy", 987654321); console.log(a.print) console.log(b.print)
28th May 2021, 3:55 PM
Eashan Morajkar
Eashan Morajkar - avatar
0
Deleted two last line And add console.log(ditto👇) function contact(name, number) { this.name = name; this.number = number; console.log(this.name+": "+this.number) } var a = new contact("David", 12345); var b = new contact("Amy", 987654321);
1st Jun 2021, 12:14 AM
MIKEY
MIKEY - avatar