-
Notifications
You must be signed in to change notification settings - Fork 0
/
script.js
24 lines (23 loc) · 857 Bytes
/
script.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
const caltemp = () => {
const numberTemp = document.getElementById('temp').value;
const tempselected = document.getElementById('temp_diff');
const valueTemp = temp_diff.options[tempselected.selectedIndex].value;
console.log(valueTemp);
const celToFah = (cel) => {
let fahrenheit = Math.round((cel * 9 / 5) + 32);
return fahrenheit;
}
const fahTocel = (fahren) => {
let celsius = Math.round((fahren - 32) * 5 / 9);
return celsius;
}
let result;
if (valueTemp == 'celsius') {
result = celToFah(numberTemp);
document.getElementById('resultcontainer').innerHTML = '=' + result + "°Fahrenheit";
}
else {
result = fahTocel(numberTemp);
document.getElementById('resultcontainer').innerHTML = "=" + result + "°celsius";
}
}