Deviopath › TypeScript

Format a Table Row

Medium · Narrowing

A table cell is type Cell = string | number | boolean | null. Write formatRow(cells: Cell[]): string that formats each cell and joins them with " | ":

- number: 2 decimals (toFixed(2))

- string: trimmed

- boolean: "yes" or "no"

- null: "-"

Narrow each cell with === and typeof checks.

Next: Pick Properties