New course! Every coder should learn Generative AI!
Try a free lesson0
Can someone please help with the print method
I can’t seem to get the the print output to print the new arguments 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();
4 Answers
+ 1
Yasin Rahnaward Please don't give ready-made code. Rather help the OP find their own solution.
+ 2
Arosanyin Daniel use:- console.log(a);
console log(b);
+ 2
Arosanyin Daniel Lisa
😊
//code project (contact number) intermediate
//Javascript
//you need to add the print method inside the
// contact function (here it play the role of class).
// it is going to work as I wrote it down.
function contact(name, number) {
this.name = name;
this.number = number;
// add this print function to your code😎😊😊👇
this.print =function(){
console.log(this.name+": "+this.number)
}}
// ☝️☝️☝️
var a = new contact("David", 12345);
var b = new contact("Amy", 987654321);
a.print();
b.print();
https://www.sololearn.com/discuss/3197455/?ref=app
0
You did not write any print() method. The task is to write a print() method for contact.