Contact Manager(JS). What's wrong with my code | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

Contact Manager(JS). What's wrong with my code

function contact(name, number) { this.name = name; this.number = number; this.print = print() } function print() { document.write(a.name":"b.number); } var a = new contact("David", 12345); var b = new contact("Amy", print ) a.print(); b.print();

14th Dec 2020, 2:31 PM
Augustine Ansah Owusu
Augustine Ansah Owusu - avatar
2 Answers
+ 5
Augustine Ansah Owusu There should be space after the colon (:) and also a & b is not accessible in the function print() function contact (name, number) { this.print = function () { console.log(name + ": " + number); } }
14th Dec 2020, 2:33 PM
A͢J
A͢J - avatar
+ 1
I Am Groot Thank you that help
14th Dec 2020, 3:34 PM
Augustine Ansah Owusu
Augustine Ansah Owusu - avatar