Doing a simple recursive function that calls another function and the scope is off to where it works the first time correctly but the next times it always sets param to undefined.
function log(string){
console.log(string)
}
function repeat(operation, num, param) {
if (num <= 0) return
operation(param)
return repeat(operation, --num)
}
repeat(log, 5, "hello there")
par? normal it doesn't existparamargument during the recursive call, so yes, it will be undefined... try thisreturn repeat(operation, --num, param)