Workshop › Wordle-style Word Guess › Step 25 of 26
While playing, the message line shows the statistics: Played 12 Won 83% Streak 4. The win rate is worked out from
won and played, rounded, and 0% before any game.
```js
const rate = stats.played ? Math.round((100 * stats.won) / stats.played) : 0
let message = 'Played ' + stats.played + ' Won ' + rate + '% Streak ' + stats.streak
```stats.played ? ... : 0 avoids dividing by zero before the first game.Math.round rounds to the nearest whole number: 2 of 3 is 66.7, shown as 67.In draw, replace the let message = 'Guess the five-letter word' line with the two lines. Press Run.
Skills: Drawing on a canvas
← Keep statistics Build it yourself: only real words →