Workshop › Candy Crush-style Match 3 › Step 25 of 29
The selection is outlined white, the hint's two gems yellow. Instead of three if blocks, one loop goes through a list
of [cell, color] pairs and skips the empty ones.
```js
// Outline the selected gem, and after five idle seconds, a possible move.
ctx.lineWidth = 3
for (const [cell, color] of [[selected, '#ffffff'], [hint && hint.a, '#fde047'], [hint && hint.b, '#fde047']]) {
if (!cell) continue
ctx.strokeStyle = color
ctx.strokeRect(LEFT + cell.c * SIZE + 2, TOP + cell.r * SIZE + 2, SIZE - 4, SIZE - 4)
}
```hint && hint.a is the hint's first cell if there is a hint, otherwise null; writing hint.a with no hint would
be an error.null) are skipped with continue.In draw, replace the whole if (selected) { ... } block with the comment and the loop.
Skills: Drawing on a canvas, Arrays and objects
← A hint after five seconds Twenty moves →