+ 2
Please help, JavaScript problem
You are working on a Contact Manager app. You have created the contact object constructor, which has two arguments, name and number. You need to add a print() method to the object, which will output the contact data to the console in the following format: name: number The given code declares two objects and calls their print() methods. Complete the code by defining the print() method for the objects.
8 odpowiedzi
+ 2
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);
+ 1
Thanks a lot
0
If you solve words task, you can write me solution
0
The Answer is:
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
Getting undefined for name any help?
0
function contact(name, number) {
this.name = name;
this.number = number;
this.print= function (x, y){
console.log(x,y)};
}
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
the above code show an undefined after each answer.
david: 12345 undefined
amy: 987654321 undefined
0
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);