GarGerry commited on
Commit
c1aba63
·
verified ·
1 Parent(s): 77455fc

Update script.js

Browse files
Files changed (1) hide show
  1. script.js +8 -1
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
+ });