This are my tasks:
As you can see, they all have "same" logic. So I wanted use function like this ->
const task71=(x)=>Math.tan(2*x+x*x);
const main=(x,dX,xEnd)=>{
while(x<=xEnd)
{
task71(x); //this part I wanna change, so it will work for task72,task73...
x+=dX;
console.log(`Y=${task71(x)}\nX=${x}`);
}
}
This works only for task71(x)
,but I have task72(x),task73(x)
,etc. What do I need to change in main(x,dx,xEnd)
function to make it work for another functions? I tried use task71(x)
as argument, but in this way the function only works with the initial value of x.
Perhaps this question is stupid, sorry, I recently started learning programming.
Via Active questions tagged javascript - Stack Overflow https://ift.tt/tdmiCHS
Comments
Post a Comment