Is there a way to create an HTML table from an array of objects?
I attempted the following code but encountered an object error:
data: [{ "slot": "10:00-11:00", "isBooked": false }, { "slot": "11:00-12:00", "isBooked": false }, { "slot": "12:00-13:00", "isBooked": false }, { "slot": "13:00-14:00", "isBooked": false }, { "slot": "14:00-15:00", "isBooked": false }, { "slot": "15:00-16:00", "isBooked": false }, { "slot": "16:00-17:00", "isBooked": false }, { "slot": "17:00-18:00", "isBooked": false }, { "slot": "18:00-19:00", "isBooked": false }]
<html>
<head>
<base target="_top">
</head>
<body>
<? var idata = data ?>
<table>
<tr>
<th>Time SLOT</th>
<th>Status</th>
</tr>
<? for (var i = 0; i < idata.length; i++) { ?>
<tr>
<? for (var key in idata[i]) { ?>
<td><?= idata[i][key] ?></td>
<? } ?>
</tr>
<? } ?>
</table>
</body>
</html>