Crear un objeto para guardar contactos
Publicado por jose cardozo (1 intervención) el 14/01/2021 17:49:35
por favor necesito ayuda, soy nuevo
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.
Input
No Input
Your Output
David:12345
Amy:987654321
Expected Output
David: 12345
Amy: 987654321
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.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
function contact(name, number) {
this.name = name;
this.number = number;
this.print=() =>{
console.log(this.name+":"+this.number);
}
}
var a = new contact("David", 12345);
var b = new contact("Amy", 987654321);
a.print();
b.print();
Input
No Input
Your Output
David:12345
Amy:987654321
Expected Output
David: 12345
Amy: 987654321
Valora esta pregunta
0