Pls what is the mistake here I Javascript | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
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