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

Project

Someone should pls help Me out..JavaScript project( contact manager ) function contact(name, number) { this.name = name; this.number = number; } var a = new contact("David", 12345); var b = new contact("Amy", 987654321); a.print(); b.print();

31st Jul 2021, 1:21 AM
Ejeh Wayne
Ejeh Wayne - avatar
10 Answers
+ 7
Ejeh Wayne To get the correct output in the contact function you want to paste the following code: this.print = () => { console.log(this.name+": "+this.number); } What this does is it prints the name and number of whatever was given as an argument to the function. Also, where you have b.print(b.number) please remove b.number so it is just b.print() This should now work, if it does please mark this as the correct awnser but if you still have problems comment here again and I will have another look
31st Jul 2021, 2:24 AM
Pieter Edwards
Pieter Edwards - avatar
+ 2
Please attempt the problem first using the skills you have learned. Once you have tried to write code but can't get the right output then you may post your code so people can help you
31st Jul 2021, 2:03 AM
Pieter Edwards
Pieter Edwards - avatar
+ 2
sure...i have done almost all my projects..i will post my attempts
31st Jul 2021, 2:12 AM
Ejeh Wayne
Ejeh Wayne - avatar
+ 2
Ejeh Wayne Sorry I need to go to bed ts 20 to 4 in the morning in the UK, I can help tomorrow
31st Jul 2021, 2:40 AM
Pieter Edwards
Pieter Edwards - avatar
+ 1
@Ejah Wayne what specific part of the code are you encountering errors on? Can you post some of your attempts so I can see where your going wrong
31st Jul 2021, 2:09 AM
Pieter Edwards
Pieter Edwards - avatar
+ 1
@ pierer edwards function contact(name, number) { this.name = name; this.number = number; } var a = new contact("David", 12345); var b = new contact("Amy", 987654321); a.print(); b.print(b.number); print()
31st Jul 2021, 2:16 AM
Ejeh Wayne
Ejeh Wayne - avatar
+ 1
sure no problem...thank you very much for helping out
31st Jul 2021, 2:41 AM
Ejeh Wayne
Ejeh Wayne - avatar
+ 1
USE THIS::::::-----:::::::: function contact(name, number) { this.name = name; this.number = number; } contact.prototype.print = function() { // TODO codes } var a = new contact("David", 12345); var b = new contact("Amy", 987654321); a.print(); b.print(); WHENEVER YOU WANT ADD FUNCTION TO THE contact object use this procedure contact.prototype.{func name} = function(...params) { // TODO codes } Just replace func_name to the name of function you want add to the contact object like the above print that I add
2nd Aug 2021, 1:10 AM
Rufai Limantawa
0
i have tried so many times...tried and tried reset my code and copy it
31st Jul 2021, 2:07 AM
Ejeh Wayne
Ejeh Wayne - avatar
0
it works ... thanks ,.. what about the second one
31st Jul 2021, 2:37 AM
Ejeh Wayne
Ejeh Wayne - avatar