I know I can simply write a while loop for this..
I’m just curious to know how to pass an argument like this:
function i(a,z){
for (a; a<2; z){
//do something...
}
}
I tried
i(0,a++);
i(0,'a++');
i(0,a=a+1);
var z = "a= a+1";
i(0,z);
and all didn’t work.
[UPDATE]
I know I can change the function into
function i(a,z){
for (a; a<2; a=a+z){
//do something...
}
}
then
i(0,1);
but what I want to know here is how I can pass that a=a+z as an argument without changing my function…
I’m not sure if I understand correctly but I guess you would want something like this:
Then you call it like this:
Note that it is very similar to what you have except that the last part of the for is a function.