Invokes a function while a test condition is true.
The condition is evaluated after executing the provided function; thus, fcn
always executes at least once.
When invoked, both the predicate function and the function to invoke are provided a single argument:
i
: iteration number (starting from zero)function to invoke
function which indicates whether to continue invoking a function
execution context for the invoked function
function predicate( i ) {
return ( i < 5 );
}
function beep( i ) {
console.log( 'beep: %d', i );
}
whilst( predicate, beep );
Checks whether an iteration number passes a test.
iteration number (starting from zero)
boolean indicating whether an iteration number passes a test