- 2
Contact manager
My code isnāt running . code_ function contact(name, number) { this.name = name; this.number = number; } print() var a = new contact("David", 12345); var b = new contact("Amy", 987654321) a.print(); b.print();
11 Answers
+ 8
Emmanuel Osemudiamen
function contact(name, number) {
this.name = name;
this.number = number;
this.print = function () {
console.log(`${this.name}: ${this.number}`)
}
}
var a = new contact("David", 12345);
var b = new contact("Amy", 987654321)
a.print();
b.print();
+ 5
this.print = function () {
return this. name + ": " this.number;
}
+ 3
function contact(name, number) {
this.name = name;
this.number = number;
}
var a = new contact("David", 12345);
var b = new contact("Amy", 987654321)
a.print();
b.print();
this.print = function () {
return this. name + ": " this.number;
}
+ 1
vivek can you send the full solution on Words it didnt work bro
0
Emmanuel Osemudiamen
Please give a MWE
https://www.sololearn.com/post/75089/?ref=app
0
function contact(name, number){
this.name=name;
this.number=number;
contact.prototype.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
function contact(name, number) {
this.name = name;
this.number = number;
this.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
function contact(name, number) {
this.name = name;
this.number = number;
this.print = function() {
return this.name+": "+this.number;
}
}
var a = new contact("David", 12345);
var b = new contact("Amy", 987654321);
console.log(a.print());
console.log(b.print());
0
function contact(name, number) {
this.name = name;
this.number = number;
this.print = function(){
var x = this.name;
var y = this.number;
console.log(x + ": " + y);
}
}
var a = new contact("David", 12345);
var b = new contact("Amy", 987654321);
a.print();
b.print();
0
function contact(name, number) {
this.name = name;
this.number = number;
this.print = both;
}
function both() {
console.log(this.name +": "+ this.number);
}
var a = new contact("David", 12345);
var b = new contact("Amy", 987654321);
a.print();
b.print();
- 1
function contact(name, number) {
this.name = name;
this.number = number;
}
var a = new contact("David", 12345);
var b = new contact("Amy", 987654321);
console.log(a.name + ":"+" " + a.number);
console.log(b.name+ ":" + " " +b.number);