- 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 ));
3 Answers
+ 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();
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)
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);