I have several functions that may or may not need to be repeated a certain number of times. The number of times is set by the user, and is stored in a variable: xTcount.
Repeat some things xTcount
times? Maybe I'm misunderstanding, but it looks pretty simple:
for(var i = 0; i < xTcount; i++) {
doSomething();
doSomethingElse();
}
If the trouble is that you don't like the look of the for
loop, or that your script requires you to build the same loop multiple times, you could extract it if you reeeaaallllly wanted to:
function repeat(fn, times) {
for(var i = 0; i < times; i++) fn();
}
repeat(doSomething, xTcount);
// ...later...
repeat(doSomethingElse, xTcount);