-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
45 lines (27 loc) · 1.17 KB
/
index.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
35
36
37
38
39
40
41
42
43
44
45
// document.getElementById("result-el").textContent = "RESULT"
var buyPrice = document.getElementById("buy-price-el")
var amount = document.getElementById("amount-el")
var sellPrice = document.getElementById("sell-price-el")
var buyResultEl = document.getElementById("buy-result-el")
var sellResultEl = document.getElementById("sell-result-el")
var profitEl = document.getElementById("profit-el")
function calculate() {
console.log("hereee")
var buyPriceValue = parseFloat(buyPrice.value)
var amountValue = parseFloat(amount.value)
var sellPriceValue = parseFloat(sellPrice.value)
var buyResult = amountValue / buyPriceValue
var sellResult = buyResult * sellPriceValue
var profit = sellResult - amountValue
buyResultEl.textContent = "₿ " + buyResult.toFixed(2)
sellResultEl.textContent = "$ " + sellResult.toFixed(2)
profitEl.textContent = "$ " + profit.toFixed(2)
}
function clearInput() {
buyPrice.value = ""
amount.value = ""
sellPrice.value = ""
buyResultEl.textContent = "₿ 0.00"
sellResultEl.textContent = "$ 0.00"
profitEl.textContent = "$ 0.00"
}