Need help with print method from contact manager challenge | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

Need help with print method from contact manager challenge

I hope you can give me a hint so I can figure this out because until this point I have not seen anything like a.print or b.print and the previous lessons don't have any examples about this. I'm supposed to define two print methods for the object a.print and b.print. 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();

16th Oct 2021, 10:30 PM
Natanael
6 Answers
+ 3
Add this.print = function contact(){ console.log(this.name+this.number)}
16th Oct 2021, 10:36 PM
Chigozie Anyaeji 🇳🇬
Chigozie Anyaeji 🇳🇬 - avatar
+ 1
ubai node.js
16th Oct 2021, 10:38 PM
Chigozie Anyaeji 🇳🇬
Chigozie Anyaeji 🇳🇬 - avatar
+ 1
function contact(name,number){ this.name=name; this.number=number; this.print=function(){ console.log(this.name+" : "+this.number); } } let a=new contact("jasy",21332); let b=new contact("fabiano",86873); a.print(); b.print();
16th Oct 2021, 10:59 PM
Jasy Fabiano
Jasy Fabiano - avatar
0
JavaScript does not have any print object or print methods.
16th Oct 2021, 10:37 PM
ubai
ubai - avatar
0
Thank you
16th Oct 2021, 10:40 PM
Natanael
0
Thanks Fabiano. I think I saw the keyword "let" way back when I was studying the Basic programming language, but I have not seen it here within Javascript so if this "let" keyword is required for this challenge, then it's strange that I was not introduced to it in previous lessons.
17th Oct 2021, 2:30 PM
Natanael