rewrite while/do-while loops as functions, as appropriate

Failing:

while ( i-- ) {
  const _i = i;
  setTimeout( () => console.log( _i ) );
}