I want to generate a form that is comfortable to look using JavaScript like this
However, I tried console.table
to do that, but it actually generated a bad form.
How I can resolve this issue?
export function showNodeVersion(metadata: Metadata[]): void {
const current = getCurrent(metadata).slice(0, 9);
const lts = getLTS(metadata).slice(0, 9);
const craft = {
Current: current.map(m => {
return m.version;
}),
LTS: lts.map(m => {
return m.version;
})
}
console.table(craft)
}
console.table
can produce a table somewhat like the desired output shown, but with some caveats:
console.log
,Copy and past the following into your browser console and press enter to see the output (Code Snippets don't appear to support console.table
).
// 4 rows of dummy data:
const sep = /,\s*/;
const CURRENT = "21.4.0, 21.3.0, 21.2.0, 21.1.0" .split(sep);
const LTS = "20.10.0, 20.9.0, 18.19.0, 18.18.2" .split(sep);
const table = [];
const nRows = 4;
for( let i = 0; i < nRows; ++ i) {
table.push( {CURRENT: CURRENT[i], LTS: LTS[i]})
}
console.table( table, ["CURRENT", "LTS"]);
If the caveats are acceptable you would still need to create the table data for the four columns shown in the post's desired output.