Kaynağa Gözat

HW js01 fixed

ivar_n 2 yıl önce
ebeveyn
işleme
4683093174
1 değiştirilmiş dosya ile 7 ekleme ve 4 silme
  1. 7 4
      js/01/ExchangeRates/app.js

+ 7 - 4
js/01/ExchangeRates/app.js

@@ -10,18 +10,21 @@ fetch('https://open.er-api.com/v6/latest/USD')
       const ratesForm = document.forms.rates
       const firstField = ratesForm.first_field
       const secondField = ratesForm.second_field
+      const firstList = ratesForm.first_list
+      const secondList = ratesForm.second_list
+
       
       for (const key in currencyRates) {
         const newOption = new Option(key, currencyRates[key])
-        ratesForm.first_list.append(newOption)
-        ratesForm.second_list.append(newOption.cloneNode(true))
+        firstList.append(newOption)
+        secondList.append(newOption.cloneNode(true))
       }
       
       ratesForm.addEventListener("input", (event) => {
          const actionEl = event.target
 
-         const firstCurrency = parseFloat(ratesForm.first_list.value)
-         const secondCurrency = parseFloat(ratesForm.second_list.value)
+         const firstCurrency = parseFloat(firstList.value)
+         const secondCurrency = parseFloat(secondList.value)
       
          const firstAmount = parseFloat(firstField.value)
          const secondAmount = parseFloat(secondField.value)