Suppose I have a function roll() that randomly returns a value 1-6. Now, if I have another function called repeatFunction that takes a function as a parameter and a number n. The repeatFunction's purpose is to call whatever function it has as a parameter n times. However, if I were to pass roll() as a parameter, the repeatFunction would interpret it as whichever value 1-6 the roll() function returned, rather than a function. My code currently is as follows:
function repeatFunction(func, n){
for(i = 0; i < n; i++){
func;
}
}
repeatFunction(roll(), 10);
How do I get it so repeatFunction interprets the func parameter as a function rather than a returned value so that I can call it again within the repeatFunction?