Item 2 passes w/o any operations being performed.
switheyw opened this issue · 0 comments
switheyw commented
The first function below, does not make any calls to operation(), but is still seen as correct.
This is so even though only dashes were logged to console.
function repeat(operation, num) {
if ( num == 0 )
return
repeat(operation, num - 1);
}
The solution as supplied:
function repeat(operation, num) {
if (num <= 0) return
operation()
return repeat(operation, --num)
}