Please associate the "testData" constructor function below with a method called "mymethod": | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
- 1

Please associate the "testData" constructor function below with a method called "mymethod":

function testData (first, second) { this.first = first; this.second = second; this.checkData = ; }

13th Mar 2018, 12:05 PM
Chandra Mani Mishra
Chandra Mani Mishra - avatar
8 Answers
+ 3
function testData (first, second) { this.first = first; this.second = second; this.checkData = mymethod; }
17th May 2018, 2:57 AM
Fariza Abdullah
Fariza Abdullah - avatar
+ 2
mymethod
19th Dec 2023, 11:01 PM
JOEL ENDE NATHANIEL
JOEL ENDE NATHANIEL - avatar
+ 1
please see the code below // declare a constructor function student(id, name, dept){ this.name = name; this.id =id; this.dept = dept; //adding method this.changeName = function change(name){ this.name = name; } } //create an object var student1 = new student("1","Arif","SE"); console.log(student1.name) //output "Arif" //change the name & contain in a variable var accessMethod = student1.changeName("Rahim"); console.log(student1.name); //"Rahim" i guess that you want to add function name myMethod , but it doesnt matter now. you have to access through your properties cause you assign the function in that properties. you cant access through that function name. There is another way to do it. at now its ok.
14th Mar 2018, 11:04 PM
Md. Al-Mustanjid
Md. Al-Mustanjid - avatar
+ 1
this.checkData = mymethod;
6th Mar 2022, 5:32 AM
hotRedPanda
+ 1
Methods ============= Please associate the "testData" constructor function below with a method called "mymethod": function testData (first, second) { this.first = first; this.second = second; this.checkData = mymethod ; }
13th Mar 2023, 9:42 AM
Md Hasan Sikder
Md Hasan Sikder - avatar
0
Hi Chandra Not sure if this is what you want function testData (first, second) { this.first = first; this.second = second; this.myMethod = function (params){ code for myMthod} ; } You can also declare externally myOtherMethod(params) { // ...do something else } }; You will find this in the course
14th Mar 2018, 8:22 AM
Mike Choy
Mike Choy - avatar
0
mymethod
29th Jul 2020, 2:49 PM
kedir.y
kedir.y - avatar
0
mymethod
14th Jan 2022, 4:11 PM
James Obinna