I am trying to fill HTML table with JavaScript function. I have a html element where I created the table and I will get data from backend endpoint that's why i am trying to add the date dynamical.
<script>
const items = [
{item: "Americano", quantity: 1, total: "12.52 sar" },
{item: "Frape", quantity: 3, total: "13.40 sar" },
{item: "Espresso", quantity: 2, total: "10.12 sar" },
];
for (let i = 0; i < items.length; i++) {
let item = document.getElementById("item");
let quantity = document.getElementById("quantity");
let total = document.getElementById("total");
}
</script>
<table id="table">
<tr>
<th >Item</th>
<th>Quantity</th>
<th >Total</th>
</tr>
<tr>
<td id="item"></td>
<td id="quantity"></td>
<td id="total"></td>
</tr>
</table>