0

Pls what is the mistake here I Javascript

function contact(name, number) { this.name = name; this.number = number; this.contactdata = print() function print(){ console.log(name + ": " + number) } } var a = new contact("David ", 12345); var b = new contact("Amy ", 987654321); a.print(); b.print();

13th Jul 2022, 6:55 AM
Elijah Adebanwo
Elijah Adebanwo - avatar
1 Answer
+ 5
Elijah Adebanwo You have created contactdata function not print function. Function creation is wrong this.print = function (){ console.log(this.name + ": " + this.number)
13th Jul 2022, 7:02 AM
AÍąJ
AÍąJ - avatar