Workshop › Minesweeper › Step 24 of 26
When the game ends, the clock stops: lose and win remember the end time, and a finished game shows the time
between start and end.
```js
let endTime
endTime = 0
function lose() {
state = 'lost'
endTime = now
function win() {
state = 'won'
endTime = now
const seconds = state === 'ready' ? 0 : Math.floor(((state === 'playing' ? now : endTime) - startTime) / 1000)
```endTime is set when the game is lost or won.? : picks now while playing and endTime after the end.let startTime, write let endTime; in newGame, endTime = 0.lose and in win, under the state = ... line, write endTime = now.draw, change now in the seconds line to (state === 'playing' ? now : endTime).Skills: Game states