GarGerry commited on
Commit
5485a06
·
verified ·
1 Parent(s): ca7bcbd

Update script.js

Browse files
Files changed (1) hide show
  1. script.js +3 -2
script.js CHANGED
@@ -21,7 +21,7 @@ swapButton.addEventListener('click', async () => {
21
  fromCurrency.value = toCurrency.value;
22
  toCurrency.value = temp;
23
 
24
- // Jika autoConvert aktif, langsung lakukan konversi
25
  if (autoConvert) {
26
  convertCurrency();
27
  } else {
@@ -39,7 +39,7 @@ swapButton.addEventListener('click', async () => {
39
  });
40
 
41
  element.addEventListener('change', () => {
42
- // Reset autoConvert, tampilkan tombol Convert kembali
43
  autoConvert = false;
44
  convertButton.style.display = 'block';
45
  resultDiv.innerHTML = '';
@@ -52,6 +52,7 @@ async function convertCurrency() {
52
  const from = fromCurrency.value;
53
  const to = toCurrency.value;
54
 
 
55
  if (!amount || amount <= 0) {
56
  resultDiv.innerHTML = 'Please enter a valid amount.';
57
  return;
 
21
  fromCurrency.value = toCurrency.value;
22
  toCurrency.value = temp;
23
 
24
+ // Lakukan konversi langsung jika autoConvert aktif
25
  if (autoConvert) {
26
  convertCurrency();
27
  } else {
 
39
  });
40
 
41
  element.addEventListener('change', () => {
42
+ // Tampilkan tombol Convert jika ada perubahan manual
43
  autoConvert = false;
44
  convertButton.style.display = 'block';
45
  resultDiv.innerHTML = '';
 
52
  const from = fromCurrency.value;
53
  const to = toCurrency.value;
54
 
55
+ // Validasi input
56
  if (!amount || amount <= 0) {
57
  resultDiv.innerHTML = 'Please enter a valid amount.';
58
  return;