Lowest price ever! Learn Generative AI for 48% less!
Get my discount0
Contact Manager unsolved help me to solve it!!
I've already applied all tactics what I have knowledge js but still unable to figure out the output would you please help me? Thank you . The code is as follows:: function contact(name, number) { this.name = name; this.number = number; } var a = new contact("David", 12345); var b = new contact("Amy", 987654321); function newContact(name, number); a.print("name: " + a.name + "number: " + a.number); console.log(a.print()); b.print("name: " + b.name + "number: " + b.number); console.log(b.print());
4 Answers
+ 3
Sony Hossain
make print function not newContact function.
And also no need to print extra things just print values inside print function
this.print = function() {
console.log(this.name + ': ' + this.number;
}
now just call
a.print()
b.print()
+ 3
Sony Hossain
You have to create print function inside given function 'contact'
Making new function 'newContact' doesn't make any sense.
Read the lesson again and try to solve
+ 1
Actual Code is:.
function contact(name, number) {
this.name = name;
this.number = number;
this.print = function(){
console.log("Name: " + this.name + ", " + " Number: " + this.number);
}
}
var a = new contact("David", 12345);
var b = new contact("Amy", 987654321);
a.print();
b.print();
Thank you so much....
0
function contact(name, number) {
this.name = name;
this.number = number;
this.newContact = function(contact){
this.print() = print(name, number);
}
}
var a = new contact("David", 12345);
var b = new contact("Amy", 987654321);
a.print("Name: " + a.name + "Number: " + a.number);
console.log(a.print());
b.print("Name: " + b.name + "Number: " + b.number);
console.log(b.print());