-
Notifications
You must be signed in to change notification settings - Fork 35
/
Copy pathindex.html
83 lines (76 loc) · 1.83 KB
/
index.html
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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>ShortHand Property Names</title>
<link rel="stylesheet" href="css/styles.css">
</head>
<body>
<main>
<h1>
La mejor. <br>
Para los mejores
</h1>
<div class="hero">
<div class="wrapper">
<div class="hero-content">
<div class="mac"></div>
<div class="app">
<p>
<strong>
Precio:
</strong>
<span id="price">-</span>
</p>
<p>
<strong>
Precio oferta:
</strong>
<span id="offer">-</span>
</p>
<p>
<strong>
Precio Final:
</strong>
<span id="final-price">-</span>
</p>
<button class="button" id="make-offer">Regatear</button>
</div>
</div>
</div>
</div>
</main>
<script>
const price = 2700
const macbook = {
price,
// getPrice: function() {
// },
get finalPrice() {
return this.price * 1.16
},
set offer(offer) {
this.price -= offer
},
getPrice() {
console.log(this.price)
},
*discount(offer) {
let price = this.finalPrice
while (true) {
yield price -= offer
}
}
}
window.price.textContent = macbook.price
macbook.offer = 500
window.offer.textContent = macbook.price
window['final-price'].textContent = macbook.finalPrice
const makeAnOffer = macbook.discount(15)
window['make-offer'].addEventListener('click', () => {
window['final-price'].textContent = makeAnOffer.next().value
})
</script>
</body>
</html>