-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscripts.js
More file actions
89 lines (85 loc) · 1.45 KB
/
scripts.js
File metadata and controls
89 lines (85 loc) · 1.45 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
// Mock data (could be from an API or DB)
var products = [
{
photo: "img/big-mac.png",
name: "Big Mac",
price: 5.99,
active: false,
quantity: 1,
},
{
photo: "img/mc-chicken.png",
name: "Mc Chicken",
price: 4.99,
active: false,
quantity: 1,
},
{
photo: "img/double-cb.png",
name: "Double Cheese Burger",
price: 2.99,
active: false,
quantity: 1,
},
{
photo: "img/fries.png",
name: "Fries",
price: 2.99,
active: false,
quantity: 1,
},
{
photo: "img/nuggets.png",
name: "Mc Nuggets",
price: 3.49,
active: false,
quantity: 1,
},
{
photo: "img/salad.png",
name: "Salad",
price: 2.79,
active: false,
quantity: 1,
},
{
photo: "img/cola.png",
name: "Coke",
price: 1.99,
active: false,
quantity: 1,
},
{
photo: "img/lipton.png",
name: "Ice Tea",
price: 1.99,
active: false,
quantity: 1,
},
{
photo: "img/water.png",
name: "Water",
price: 1.49,
active: false,
quantity: 1,
},
];
const SelfServiceMachine = {
data() {
return {
products: window.products,
};
},
methods: {
total: function() {
let total = 0;
this.products.forEach(product => {
if (product.active) {
total += (product.quantity * product.price)
}
});
return total.toFixed(2);
}
}
};
Vue.createApp(SelfServiceMachine).mount("#app");