-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
28 lines (25 loc) · 877 Bytes
/
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
const celciusE1 = document.getElementById("celcius");
const FahrenheitE1 = document.getElementById("Fahrenheit");
const KelvinE1 = document.getElementById("Kelvin");
function computeTemp() {
const currentValue = +event.target.value;
switch (event.target.name) {
case "Celcius":
KelvinE1.value = currentValue + 273.15
FahrenheitE1.value = currentValue * 1.8 + 32;
KelvinE1;
break;
case "Fahrenheit":
celciusE1.value = (currentValue - 32) / 1.8;
KelvinE1.value = (currentValue - 32) / 1.8 + 273.15;
KelvinE1;
break;
case "Kelvin":
celciusE1.value = currentValue + 273.15
FahrenheitE1.value = (currentValue - 273.15) * 1.8 + 32;
KelvinE1;
break;
default:
break;
}
}