Create script.js
Browse files
script.js
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
function calculateWR() {
|
| 2 |
+
const totalMatch = parseFloat(document.getElementById('totalMatch').value);
|
| 3 |
+
const currentWR = parseFloat(document.getElementById('currentWR').value);
|
| 4 |
+
const targetWR = parseFloat(document.getElementById('targetWR').value);
|
| 5 |
+
|
| 6 |
+
if (isNaN(totalMatch) || isNaN(currentWR) || isNaN(targetWR)) {
|
| 7 |
+
alert("Harap masukkan angka yang valid.");
|
| 8 |
+
return;
|
| 9 |
+
}
|
| 10 |
+
|
| 11 |
+
const currentWins = (currentWR / 100) * totalMatch;
|
| 12 |
+
const targetMatch = totalMatch;
|
| 13 |
+
const requiredWins = (targetWR / 100) * targetMatch;
|
| 14 |
+
|
| 15 |
+
const additionalWins = requiredWins - currentWins;
|
| 16 |
+
|
| 17 |
+
const resultText = additionalWins > 0
|
| 18 |
+
? `Anda memerlukan ${Math.ceil(additionalWins)} kemenangan lagi untuk mencapai WR ${targetWR}%.`
|
| 19 |
+
: `Anda sudah melampaui WR yang diinginkan!`;
|
| 20 |
+
|
| 21 |
+
document.getElementById('result').innerText = resultText;
|
| 22 |
+
}
|