File tree Expand file tree Collapse file tree 1 file changed +4
-4
lines changed
Expand file tree Collapse file tree 1 file changed +4
-4
lines changed Original file line number Diff line number Diff line change 11```
22var table = function(input) {
33 let pad = String(input.length).length;
4- let space = ' '.padStart(pad) + ' ' ;
5- let header = space + ` | ${input.join(' | ')} |`;
6- let line = space + Array( header.length - space.length).fill( '-').join('');
4+ let space = '# '.padStart(pad);
5+ let header = `| ${ space} | ${input.join(' | ')} |`;
6+ let line = header.split('').map(c => c === '|' ? '|' : '-').join('');
77 let grid = [];
88
99 let mid = Math.floor(input.length / 2);
@@ -32,7 +32,7 @@ var table = function(input) {
3232 row.push(char);
3333 }
3434
35- grid.push(`${(y+1).toString().padStart(pad)} | ${row.join(' | ')} |`);
35+ grid.push(`| ${(y+1).toString().padStart(pad)} | ${row.join(' | ')} |`);
3636 }
3737
3838 let output = [header, line, ...grid].join('\n');
You can’t perform that action at this time.
0 commit comments