int time = 0;
int max_period = 10000;
void loop() {
if (time % 100 == 0) {
everyTenthSecond();
}
if (time % 1000 == 0) {
everySecond();
}
// ...
time = (time + 1) % max_period;
}
This `loop` assumes functions are perfectly non-blocking, which obviously is not always true, but works well for 99% of actual use cases. If keeping accurate time is required, the student would compare `time` with the elapsed millisecond time since the last loop invocation, adjust accordingly, and check for any periodic functions that weren't executed in that period. It gets tedious quite fast.If I had to imagine a solution, it would be to simply have an easy way to enter parameters to the JS-equivalent of `setTimeout` and `setInterval`.