I have the following code that works. However, there is a lot of repetition. Here is the code.
<tr>
<th>Brand</th>
<td>{ a_data.brand }</td>
<td>{ b_data.brand }</td>
<td>{ c_data.brand }</td>
</tr>
<tr>
<th>Model</th>
<td>{ a_data.model }</td>
<td>{ b_data.model }</td>
<td>{ c_data.model }</td>
</tr>
<tr>
<th>Variant</th>
<td>{ a_data.variant }</td>
<td>{ b_data.variant }</td>
<td>{ c_data.variant }</td>
</tr>
I have tried to create an array const data = ['a_data', 'b_data', 'c_data']; and loop through that to dynamically display the variables with forEach as well as map. But it does not display anything.
How can I put this in a loop?
{ data.map(datum => <td>{ datum.variant }</td>) }