Skip to content

Instantly share code, notes, and snippets.

@dallashuggins
Last active July 6, 2019 02:16
Show Gist options
  • Save dallashuggins/46a796e970aaefa71aea50ad8c845ca9 to your computer and use it in GitHub Desktop.
Save dallashuggins/46a796e970aaefa71aea50ad8c845ca9 to your computer and use it in GitHub Desktop.
Dynamic Table for JS interview
function table ({ columns, items }) {
return (
<table>
<thead>
<tr>
{columns.map(col => (
<th>{col.key}</th>
))}
</tr>
</thead>
<tbody>
<tr>
{items.map(item => (
<tr>
{columns.map(col =>
<td>{item[col.key]}</td>
)}
</tr>
))}
</tr>
</tbody>
</table>
)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment