I have lots of functions similar to FunctionOne. Difference in these is five = this.methodTwo(two, three, four, five). I don't want to repeat code. For doing that, how can I pass function's return value as parameter?
class MyClass {
FunctionOne(one, two, three, four, five) {
//some code here
one = "my one";
two = "my two";
five = this.FunctionTwo(two, three, four, five); //How can I pass this as parameter
one[five] = "something";
return one;
}
FunctionThree(one, two, three, four, five) {
//some code here
one = "my one";
two = "my two";
five = this.FunctionFour(two, three, four, five); //Everything in FunctionThree is same as FunctionOne except this statement
one[five] = "something";
return one;
}
FunctionTwo(two, three, four, five) {
//some code
return five;
}
}
FunctionX(one, two, three, four, five, fn) {…}and could be called likex = FunctionX(h, i, j, k, l, FunctionOne)