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);

1st Aug 2023, 8:17 PM
Khan
5 ответов
+ 4
Pay attention to white spaces in the output
1st Aug 2023, 9:50 PM
Lisa
Lisa - avatar
+ 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();
1st Aug 2023, 8:48 PM
ClickGames
ClickGames - avatar
0
Keep the right decision
1st Aug 2023, 8:50 PM
ClickGames
ClickGames - avatar
0
What's the point?
1st Aug 2023, 11:26 PM
ClickGames
ClickGames - avatar
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
2nd Aug 2023, 2:04 AM
Khan