Workshop › Whack-a-Mole › Step 14 of 18
To make the game harder as it goes, we first need a number for how far the round is: 0 at the start, 1 at the end.
```js
// 0 when the round starts, 1 when it ends.
function progress() {
return Math.min(1, Math.max(0, 1 - (endsAt - now) / ROUND))
}
```(endsAt - now) / ROUND is the part of the round still left: 1 at the start, 0 at the end. One minus it is the part done.Math.max(0, ...) and Math.min(1, ...) keep the answer between 0 and 1, even before or after the round.Under isUp, write the comment and progress.
Skills: Functions
← Best score Faster and faster →