I am working on a simple higher-order function, delay
, that will invoke a function parameter, func
, and then delay by an amount of time passed in as wait
. I have read other answers about where to put in parameters, but none of the answers I found addressed exactly what I need to learn: where and how should I allow for the parameters that may or may not be passed to func
?
Original instructions: "Invokes func after wait milliseconds. Any additional arguments are provided to func when it is invoked."
Here's the basic start:
function delay(func, wait) {
setInterval(func, wait);
}
Another answer on SO states that an anonymous function can be used to wrap the func
parameter so that the parameters can be passed in there, but I haven't had any success building that yet.
Guidance is greatly appreciated.