[ {
"course": "Bachelor of Computer Science",
"level": "Bachelor's Degree",
"provider": [
{
"school": "Harvard University",
"duration": "156"
},
{
"school": "Yales University",
"duration": "156"
},
{
"school": "BYU-Provo",
"duration": "208"
}
]
}
]
I am retrieving information from an API and the format is similar to the above code snippet. I aim to display this data in a table, so I improvised with the following approach:
data.map((item) => {
return `
<tr class="grid-row">
<td>${item.course}</td>
<td>${item.level}</td>
${provider(item.provider)} // Loops through the provider array
</tr>
The current output of the table looks like:
Course | Level | Provider |
---|---|---|
Science | BSC. | Harvard University Yales University BYU-PROVO |
I want to dynamically generate new rows for each individual provider under the same course and level. This way, the updated table would look like:
Course | Level | Provider |
---|---|---|
Science | BSC. | Harvard University |
Science | BSC. | Yales University |
Science | BSC. | BYU-Provo |