File tree 2 files changed +12
-8
lines changed 2 files changed +12
-8
lines changed Original file line number Diff line number Diff line change 1
- const convertToCelsius = function ( ) {
1
+ const convertToCelsius = function ( fahrenheit ) {
2
+ let cel = ( ( fahrenheit - 32 ) * 5 / 9 ) . toFixed ( 1 )
3
+ return parseFloat ( cel ) ;
2
4
} ;
3
5
4
- const convertToFahrenheit = function ( ) {
6
+ const convertToFahrenheit = function ( celsius ) {
7
+ let fah = ( ( celsius * ( 9 / 5 ) ) + 32 ) . toFixed ( 1 )
8
+ return parseFloat ( fah )
5
9
} ;
6
10
7
11
// Do not edit below this line
Original file line number Diff line number Diff line change 1
- const { convertToCelsius, convertToFahrenheit} = require ( './tempConversion' )
1
+ const { convertToCelsius, convertToFahrenheit } = require ( './tempConversion' )
2
2
3
3
describe ( 'convertToCelsius' , ( ) => {
4
4
test ( 'works' , ( ) => {
5
5
expect ( convertToCelsius ( 32 ) ) . toEqual ( 0 ) ;
6
6
} ) ;
7
- test . skip ( 'rounds to 1 decimal' , ( ) => {
7
+ test ( 'rounds to 1 decimal' , ( ) => {
8
8
expect ( convertToCelsius ( 100 ) ) . toEqual ( 37.8 ) ;
9
9
} ) ;
10
- test . skip ( 'works with negatives' , ( ) => {
10
+ test ( 'works with negatives' , ( ) => {
11
11
expect ( convertToCelsius ( - 100 ) ) . toEqual ( - 73.3 ) ;
12
12
} ) ;
13
13
} ) ;
14
14
15
15
describe ( 'convertToFahrenheit' , ( ) => {
16
- test . skip ( 'works' , ( ) => {
16
+ test ( 'works' , ( ) => {
17
17
expect ( convertToFahrenheit ( 0 ) ) . toEqual ( 32 ) ;
18
18
} ) ;
19
- test . skip ( 'rounds to 1 decimal' , ( ) => {
19
+ test ( 'rounds to 1 decimal' , ( ) => {
20
20
expect ( convertToFahrenheit ( 73.2 ) ) . toEqual ( 163.8 ) ;
21
21
} ) ;
22
- test . skip ( 'works with negatives' , ( ) => {
22
+ test ( 'works with negatives' , ( ) => {
23
23
expect ( convertToFahrenheit ( - 10 ) ) . toEqual ( 14 ) ;
24
24
} ) ;
25
25
} ) ;
You can’t perform that action at this time.
0 commit comments