diff --git a/07_tempConversion/tempConversion.js b/07_tempConversion/tempConversion.js index 14153e0..0128aa3 100644 --- a/07_tempConversion/tempConversion.js +++ b/07_tempConversion/tempConversion.js @@ -1,11 +1,17 @@ -const convertToCelsius = function() { -}; +const round = function (number) { + return Math.round(number * 10) / 10 +} -const convertToFahrenheit = function() { -}; +const convertToCelsius = function (F) { + return round((F - 32) * (5 / 9)) +} + +const convertToFahrenheit = function (C) { + return round((C * (9 / 5)) + 32) +} // Do not edit below this line module.exports = { convertToCelsius, - convertToFahrenheit -}; + convertToFahrenheit, +} diff --git a/07_tempConversion/tempConversion.spec.js b/07_tempConversion/tempConversion.spec.js index c4f9742..95324ed 100644 --- a/07_tempConversion/tempConversion.spec.js +++ b/07_tempConversion/tempConversion.spec.js @@ -2,24 +2,24 @@ const {convertToCelsius, convertToFahrenheit} = require('./tempConversion') describe('convertToCelsius', () => { test('works', () => { - expect(convertToCelsius(32)).toEqual(0); - }); - test.skip('rounds to 1 decimal', () => { - expect(convertToCelsius(100)).toEqual(37.8); - }); - test.skip('works with negatives', () => { - expect(convertToCelsius(-100)).toEqual(-73.3); - }); -}); + expect(convertToCelsius(32)).toEqual(0) + }) + test('rounds to 1 decimal', () => { + expect(convertToCelsius(100)).toEqual(37.8) + }) + test('works with negatives', () => { + expect(convertToCelsius(-100)).toEqual(-73.3) + }) +}) describe('convertToFahrenheit', () => { - test.skip('works', () => { - expect(convertToFahrenheit(0)).toEqual(32); - }); - test.skip('rounds to 1 decimal', () => { - expect(convertToFahrenheit(73.2)).toEqual(163.8); - }); - test.skip('works with negatives', () => { - expect(convertToFahrenheit(-10)).toEqual(14); - }); -}); + test('works', () => { + expect(convertToFahrenheit(0)).toEqual(32) + }) + test('rounds to 1 decimal', () => { + expect(convertToFahrenheit(73.2)).toEqual(163.8) + }) + test('works with negatives', () => { + expect(convertToFahrenheit(-10)).toEqual(14) + }) +})