- 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 odpowiedzi
+ 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