Skip to content

Instantly share code, notes, and snippets.

@minkcv
Last active August 31, 2018 03:05
Show Gist options
  • Select an option

  • Save minkcv/345366242578dc5f86c0987157f43f99 to your computer and use it in GitHub Desktop.

Select an option

Save minkcv/345366242578dc5f86c0987157f43f99 to your computer and use it in GitHub Desktop.
Probably the absolute worst code I have ever written. 8/29/18
// This is probably the absolute worst code I have ever written. 8/29/18
var data = [
['AAAAAA', 'BBBBBB', 'CCCCCC'],
['a', 'a', 'c'],
['a', 'a', 'c'],
['a', 'a', 'c'],
['a', 'a', 'c']
];
var html = `
<div id='data-component'>
<table class='data-table'>
`;
html +=`
<thead>
<tr>
`;
for (var i = 0; i < data[0].length; i++) {
html +=`
<th><pre>` + data[0][i] + `</pre></th>
`;
}
html +=`
</tr>
</thead>
<tbody>
`;
for (var i = 1; i < data.length; i++) {
html += ` <tr>`
for (var j = 0; j < data[i].length; j++) {
html +=`
<td><pre>` + data[i][j] + `</pre></td>
`;
}
html += ` </tr>`
}
html += `
</tbody>
</table>
</div>
`;
@minkcv
Copy link
Author

minkcv commented Aug 31, 2018

Revised to remove extraneous html attributes. The focus of the gist is to illustrate messiness of the js and html interaction.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment