From 478676904fdd1984abec95fc8aaceffa7b40ac05 Mon Sep 17 00:00:00 2001 From: Thuan Bui <9248622+10h30@users.noreply.github.com> Date: Sat, 22 Feb 2025 10:53:29 +0900 Subject: [PATCH] Complete 7 --- 07_tempConversion/tempConversion.js | 8 ++++++-- 07_tempConversion/tempConversion.spec.js | 10 +++++----- 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/07_tempConversion/tempConversion.js b/07_tempConversion/tempConversion.js index 14153e0..2af6576 100644 --- a/07_tempConversion/tempConversion.js +++ b/07_tempConversion/tempConversion.js @@ -1,7 +1,11 @@ -const convertToCelsius = function() { +const convertToCelsius = function(degreeinF) { + degreeinC = Math.round(((degreeinF - 32) / 1.8) * 10)/10 + return degreeinC }; -const convertToFahrenheit = function() { +const convertToFahrenheit = function(degreeinC) { + degreeinF = Math.round(((degreeinC* 1.8) + 32) * 10)/10 + return degreeinF }; // Do not edit below this line diff --git a/07_tempConversion/tempConversion.spec.js b/07_tempConversion/tempConversion.spec.js index c4f9742..7d0cc93 100644 --- a/07_tempConversion/tempConversion.spec.js +++ b/07_tempConversion/tempConversion.spec.js @@ -4,22 +4,22 @@ describe('convertToCelsius', () => { test('works', () => { expect(convertToCelsius(32)).toEqual(0); }); - test.skip('rounds to 1 decimal', () => { + test('rounds to 1 decimal', () => { expect(convertToCelsius(100)).toEqual(37.8); }); - test.skip('works with negatives', () => { + test('works with negatives', () => { expect(convertToCelsius(-100)).toEqual(-73.3); }); }); describe('convertToFahrenheit', () => { - test.skip('works', () => { + test('works', () => { expect(convertToFahrenheit(0)).toEqual(32); }); - test.skip('rounds to 1 decimal', () => { + test('rounds to 1 decimal', () => { expect(convertToFahrenheit(73.2)).toEqual(163.8); }); - test.skip('works with negatives', () => { + test('works with negatives', () => { expect(convertToFahrenheit(-10)).toEqual(14); }); });