<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>JS Assignment</title>
</head>
<body>
<button onclick="order1.displayOrder()">Order1</button>
<button onclick="order2.displayOrder()">Order2</button>
<script>
const order1 = {
customer_name: "John",
drink_type: "latte",
coffee_size: "short",
drizzle: "yes",
whipped_cream: "yes",
sweetener: "no",
cold_foam: "yes",
dairy: "Cream",
displayOrder: function () {
let ordertotal = "Customer Name : " + this.customer_name;
ordertotal += "\n" + "Drink Type : " + this.drink_type;
ordertotal += "\n" + "Coffee Size : " + this.coffee_size;
ordertotal += "\n" + "Drizzle";
ordertotal += this.whipped_cream ? "\n" + "Whipped Cream" : "";
ordertotal += this.sweetener ? "\n" + "Sweetener" : "";
ordertotal += this.cold_foam ? "\n" + "Cold Foam" : "";
ordertotal += this.dairy ? "\n" + this.dairy : "";
alert(ordertotal);
},
};
const order2 = {
customer_name: "Sarah",
drink_type: "expresso",
coffee_size: "venti",
drizzle: "no",
whipped_cream: "no",
sweetener: "yes",
cold_foam: "yes",
dairy: "2% milk",
displayOrder: function () {
let ordertotal = "Customer Name : " + this.customer_name;
ordertotal += "\n" + "Drink Type : " + this.drink_type;
ordertotal += "\n" + "Coffee Size : " + this.coffee_size;
ordertotal += "\n" + "Drizzle";
ordertotal += this.whipped_cream ? "\n" + "Whipped Cream" : "";
ordertotal += this.sweetener ? "\n" + "Sweetener" : "";
ordertotal += this.cold_foam ? "\n" + "Cold Foam" : "";
ordertotal += this.dairy ? "\n" + this.dairy : "";
alert(ordertotal);
},
};
</script>
</body>