diff --git a/src/index.ts b/src/index.ts index e1b1c51..0e5a659 100644 --- a/src/index.ts +++ b/src/index.ts @@ -32,7 +32,7 @@ export function textTable(rows: string[][], opts: TextTableOptions = {}) { row.forEach(function (row, i) { const rowLength = stringLength(row); - if (!acc[i] || rowLength > acc[i]) { + if (i >= acc.length || !acc[i] || rowLength > acc[i]) { acc[i] = rowLength; } });