forked from Pratik-007/Temprature
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
26 lines (22 loc) · 785 Bytes
/
script.js
File metadata and controls
26 lines (22 loc) · 785 Bytes
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
const calculateTemp = () => {
const numberTemp = document.getElementById('temp').value;
const tempSelected = document.getElementById('temp_diff');
const valueTemp = temp_diff.options[tempSelected.selectedIndex].value;
const celTofeh=(cel)=>{
let fahrenheit = Math.round((cel*9/5)+32);
return fahrenheit;
}
const fehTocel=(feh)=>{
let celsius = Math.round((feh -32)* 5/9);
return celsius;
}
let result ;
if(valueTemp == 'cel'){
result = celTofeh(numberTemp);
document.getElementById('resultContainer').innerHTML =`= ${result} °Fahrenheit`;
}else
{
result = fehTocel(numberTemp);
document.getElementById('resultContainer').innerHTML =`= ${result} °Celcius`;
}
}