Spaces:
Running
Running
Update index.html
Browse files- index.html +11 -3
index.html
CHANGED
@@ -49,7 +49,7 @@
|
|
49 |
<div class="slot" id="slot3">π</div>
|
50 |
</div>
|
51 |
<button id="spin-btn">Spin</button>
|
52 |
-
<div id="balance">Balance: $<span id="balance-amount">10</span></div>
|
53 |
<div id="history"></div>
|
54 |
|
55 |
<script>
|
@@ -61,14 +61,22 @@
|
|
61 |
var balanceAmount = document.getElementById('balance-amount');
|
62 |
var history = document.getElementById('history');
|
63 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
64 |
slot1.textContent = emojis[Math.floor(Math.random() * emojis.length)];
|
65 |
slot2.textContent = emojis[Math.floor(Math.random() * emojis.length)];
|
66 |
slot3.textContent = emojis[Math.floor(Math.random() * emojis.length)];
|
67 |
|
68 |
if (slot1.textContent === slot2.textContent && slot2.textContent === slot3.textContent) {
|
69 |
var winAmount = Math.floor(Math.random() * 100) + 1;
|
70 |
-
|
71 |
-
balanceAmount.textContent = newBalance;
|
72 |
history.innerHTML += '<p>You won $' + winAmount + '! π</p>';
|
73 |
}
|
74 |
});
|
|
|
49 |
<div class="slot" id="slot3">π</div>
|
50 |
</div>
|
51 |
<button id="spin-btn">Spin</button>
|
52 |
+
<div id="balance">Balance: $<span id="balance-amount">10.00</span></div>
|
53 |
<div id="history"></div>
|
54 |
|
55 |
<script>
|
|
|
61 |
var balanceAmount = document.getElementById('balance-amount');
|
62 |
var history = document.getElementById('history');
|
63 |
|
64 |
+
// Deduct 25 cents
|
65 |
+
var newBalance = parseFloat(balanceAmount.textContent) - 0.25;
|
66 |
+
if (newBalance < 0) {
|
67 |
+
alert("Insufficient balance.");
|
68 |
+
return;
|
69 |
+
}
|
70 |
+
balanceAmount.textContent = newBalance.toFixed(2);
|
71 |
+
|
72 |
slot1.textContent = emojis[Math.floor(Math.random() * emojis.length)];
|
73 |
slot2.textContent = emojis[Math.floor(Math.random() * emojis.length)];
|
74 |
slot3.textContent = emojis[Math.floor(Math.random() * emojis.length)];
|
75 |
|
76 |
if (slot1.textContent === slot2.textContent && slot2.textContent === slot3.textContent) {
|
77 |
var winAmount = Math.floor(Math.random() * 100) + 1;
|
78 |
+
newBalance = parseFloat(balanceAmount.textContent) + winAmount;
|
79 |
+
balanceAmount.textContent = newBalance.toFixed(2);
|
80 |
history.innerHTML += '<p>You won $' + winAmount + '! π</p>';
|
81 |
}
|
82 |
});
|