const table = {}
table.create = function (data, cols) {
let output = '
\r\n'
output += ' \r\n '
for (let column of cols) {
output += `${column} | `
}
output += '
\r\n \r\n'
output += ' \r\n'
output += getHTMLRows(data)
output += ' \r\n'
output += '
'
return output
}
function getHTMLRows(data) {
let output = ''
for (let group of data) {
let rowspan = group.length
for (let [j, row] of group.entries()) {
output += ' '
for (let [i, value] of row.entries()) {
if (i === 0 && j === 0) {
output += `${value} | `
} else if (i > 0) {
if (typeof value === 'number') {
output += `${value} | `
} else {
output += `${value} | `
}
}
}
output += '
\r\n'
}
}
return output
}
function getSpan() {}
module.exports = table