Spaces:
Running
Running
Update script.js
Browse files
script.js
CHANGED
|
@@ -27,4 +27,11 @@ document.getElementById('currencyForm').addEventListener('submit', async functio
|
|
| 27 |
} else {
|
| 28 |
// Menyusun nilai konversi dan menampilkannya
|
| 29 |
const rate = data.conversion_rates[toCurrency];
|
| 30 |
-
const convertedAmount = (amount * rate).toFixed
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 27 |
} else {
|
| 28 |
// Menyusun nilai konversi dan menampilkannya
|
| 29 |
const rate = data.conversion_rates[toCurrency];
|
| 30 |
+
const convertedAmount = (amount * rate).toFixed(2);
|
| 31 |
+
resultDiv.innerHTML = `${amount} ${fromCurrency} = ${convertedAmount} ${toCurrency}`;
|
| 32 |
+
}
|
| 33 |
+
} catch (error) {
|
| 34 |
+
resultDiv.innerHTML = "Error fetching conversion rate.";
|
| 35 |
+
console.error("Error:", error); // Menampilkan error di konsol
|
| 36 |
+
}
|
| 37 |
+
});
|