0
Contact manager in module 1 of js intermediate
I am not sure whether, I can ask such questions or not. But I wrote a code in js for contact manager. It works fine. I am sharing my code here so that I can know that is there any alternative way to solve this? Or my code is perfect. I am just asking bcz I am a beginner and have some logical issues that takes more memory. function contact(name, number) { this.name = name; this.number = number; this.print = display } function display(name, number){ this.name = name+":"; console.log(this.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);
5 Réponses
+ 4
Pay attention to white spaces in the output
+ 3
class Contact {
constructor(name, number) {
this.name = name;
this.number = number;
}
print() {
console.log(this.name + ":" + this.number);
}
}
const david = new Contact("David", 12345);
const amy = new Contact("Amy", 987654321);
david.print();
amy.print();
0
Keep the right decision
0
What's the point?
0
ClickGames ,
First of all thanks for your help.
The point is:
In this code, output should be: there should be no whitespaces between name and colon
name: number