Write a function after that takes the number of times the callback needs to be called before being executed as the first parameter and the callback as the second parameter.
1 Answer
This sounds a bit like a homework assignment, so I'm hesitant to help you with your homework by answering the question for you ;)
Instead ... the basic idea is that you need to write a function with two arguments:
function (numberOfTimesToCall, callbackFunctionToCall) { //..
Inside you'll call the callback argument, using:
callbackFunctionToCall();
You'll want to do that a certain number of times, and in Javascript we typically use a for loop to do something a certain number of times.
For instance, to doSomething() five times, you could write:
for(var i = 0; i < 5; i++) {
doSomething();
}
2 Comments
machineghost
Glad I could help, but don't forget to accept the answer (click the checkmark next to it) if it answered your question :)
rozha
don't worry will do sir