Contact Manager Project Help | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
- 1

Contact Manager Project Help

I made a function for the objects that works fine, for some reason my string automatically places spaces when I donโ€™t think itโ€™s supposed to. function contact(name, number) { this.name = name; this.number = number; this.print = function() { console.log(name,":", number) } } var a = new contact("David", 12345); var b = new contact("Amy", 987654321) a.print(); b.print(); For some reason the end result comes out with extra spaces like โ€œDavid : 12345โ€ when the answer to solve it is โ€œDavid: 12345)โ€. I know the rule that if you add spaces to the string it adds them but I used none and they were added anyway.

1st Feb 2021, 4:05 AM
Mark
Mark - avatar
5 Answers
+ 4
Replace commas by + operator when logging to console ๐Ÿ‘
1st Feb 2021, 4:08 AM
Ipang
+ 3
Contact Manager Project is following function contact(name, number) { this.name = name; this.number = number; this.print = function() { console.log(name+":", number) } } var a = new contact("David", 12345); var b = new contact("Amy", 987654321) a.print(); b.print();
31st Mar 2021, 5:21 PM
Ravi Kumar
Ravi Kumar - avatar
+ 2
thank you i didnt even know you could do that
1st Feb 2021, 4:10 AM
Mark
Mark - avatar
+ 2
Mark thanks i was also stack๐Ÿ‘
24th Feb 2021, 10:12 PM
Dr_knowmore
Dr_knowmore - avatar
0
Good luck! ๐Ÿ‘
1st Feb 2021, 4:11 AM
Ipang