-
Notifications
You must be signed in to change notification settings - Fork 1
/
app.js
34 lines (27 loc) · 974 Bytes
/
app.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
//Selecting Elements
const amountElement = document.querySelector("#amount")
const firstCurrency = document.querySelector("#firstCurrency")
const secondCurrency = document.querySelector("#secondCurrency")
const currency = new Currency("USD","TRY")
const ui = new UI(firstCurrency,secondCurrency)
eventListener()
function eventListener(){
amountElement.addEventListener("input",exchangeCurrency)
firstCurrency.onchange = function(){
currency.changeFirstCurrency(firstCurrency.options[firstCurrency.selectedIndex].textContent)
ui.changeFirst()
}
secondCurrency.onchange = function(){
currency.changeSecondCurrency(secondCurrency.options[secondCurrency.selectedIndex].textContent)
ui.changeSecond()
}
}
function exchangeCurrency(){
currency.changeAmount(amountElement.value)
currency.exchange()
.then((result) => {
ui.displayResult(result)
}).catch((err) => {
console.log(err)
});
}