I got a situation like this:
var orders = [
{ID: "sampleID1", order: "string describing the first order"},
{ID: "sampleID2", order: "string describing the second order"}
];
const bill = document.querySelector("#ordersListed");
for(var x in orders) {
bill.innerHTML += orders[x].order;
}
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Document</title>
</head>
<body>
<div id="ordersListed"></div>
</body>
</html>
Each time I click a button, an item gets added to the array.
I've been trying to loop through the array to print each order in a HTML element.
Should show up in the div as:
string describing the first order
string describing the second order
My results:
first order
first order
second order