File tree Expand file tree Collapse file tree 1 file changed +10
-3
lines changed
project-7-temperature-converter Expand file tree Collapse file tree 1 file changed +10
-3
lines changed Original file line number Diff line number Diff line change @@ -12,10 +12,17 @@ function computeTemp (event) {
12
12
13
13
switch ( event . target . name ) {
14
14
case "celsius" :
15
- kelvinEl . value = ( currentValue + 273.32 ) ;
16
- fahrenheitEl . value = ( currentValue * 1.8 + 32 ) ;
15
+ kelvinEl . value = ( currentValue + 273.32 ) . toFixed ( 2 ) ;
16
+ fahrenheitEl . value = ( currentValue * 1.8 + 32 ) . toFixed ( 2 ) ;
17
+ break ;
18
+ case "fahrenheit" :
19
+ celsiusEl . value = ( ( currentValue - 32 ) / 1.8 ) . toFixed ( 2 ) ;
20
+ kelvinEl . value = ( ( currentValue - 32 ) / 1.8 + 273.32 ) . toFixed ( 2 ) ;
21
+ break ;
22
+ case "kelvin" :
23
+ celsiusEl . value = ( currentValue - 273.32 ) . toFixed ( 2 ) ;
24
+ fahrenheitEl . value = ( ( currentValue - 273.32 ) * 1.8 + 32 ) . toFixed ( 2 ) ;
17
25
break ;
18
-
19
26
default :
20
27
break ;
21
28
}
You can’t perform that action at this time.
0 commit comments