+ 1
Project
Someone should pls help Me out..JavaScript project( contact manager ) 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();
10 odpowiedzi
+ 7
Ejeh Wayne To get the correct output in the contact function you want to paste the following code:
this.print = () => {
console.log(this.name+": "+this.number);
}
What this does is it prints the name and number of whatever was given as an argument to the function.
Also, where you have b.print(b.number) please remove b.number so it is just b.print()
This should now work, if it does please mark this as the correct awnser but if you still have problems comment here again and I will have another look
+ 2
Please attempt the problem first using the skills you have learned. Once you have tried to write code but can't get the right output then you may post your code so people can help you
+ 2
sure...i have done almost all my projects..i will post my attempts
+ 2
Ejeh Wayne Sorry I need to go to bed ts 20 to 4 in the morning in the UK, I can help tomorrow
+ 1
@Ejah Wayne what specific part of the code are you encountering errors on? Can you post some of your attempts so I can see where your going wrong
+ 1
@ pierer edwards 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(b.number);
print()
+ 1
sure no problem...thank you very much for helping out
+ 1
USE THIS::::::-----::::::::
function contact(name, number) {
this.name = name;
this.number = number;
}
contact.prototype.print = function() {
// TODO codes
}
var a = new contact("David", 12345);
var b = new contact("Amy", 987654321);
a.print();
b.print();
WHENEVER YOU WANT ADD FUNCTION TO THE contact object use this procedure
contact.prototype.{func name} = function(...params) {
// TODO codes
}
Just replace func_name to the name of function you want add to the contact object like the above print that I add
0
i have tried so many times...tried and tried reset my code and copy it
0
it works ... thanks ,.. what about the second one