-
Notifications
You must be signed in to change notification settings - Fork 0
/
script.js
35 lines (27 loc) · 932 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
25
26
27
28
29
30
31
32
33
34
35
const tempCalculate =() =>{
const numberTemp = document.getElementById('tempr').value
// console.log(numberTemp);
const Reset =() =>{
let resetData =document.getElementById('tempr').innerHTML=""
}
const tempSelect = document.getElementById('temp_diff');
const valueTemp = temp_diff.options[tempSelect.selectedIndex].value
// console.log(valueTemp);
const celToFah = (cel)=>{
let Fahrenheit = Math.round((cel * 9/5)+32);
return Fahrenheit;
}
const fahToCel = (fehr)=>{
let celcius = Math.round((fehr -32) *5/9);
return celcius;
}
let result;
if(valueTemp == 'cel'){
result =celToFah(numberTemp);
document.getElementById('resultContain').innerHTML=`= ${result}°Fahrenheit`
}
else{
result =fahToCel(numberTemp);
document.getElementById('resultContain').innerHTML=`= ${result}°Celcius`
}
}