From 4ff7b6611fbd93061c6608fd61082f2325ce3cdd Mon Sep 17 00:00:00 2001 From: Mateusz Bujak <62397807+M-Bujak@users.noreply.github.com> Date: Sat, 23 Jul 2022 14:20:28 +0200 Subject: [PATCH] solved 07 --- 07_tempConversion/tempConversion.js | 9 ++++++--- 07_tempConversion/tempConversion.spec.js | 10 +++++----- 2 files changed, 11 insertions(+), 8 deletions(-) diff --git a/07_tempConversion/tempConversion.js b/07_tempConversion/tempConversion.js index 6ef3e85..828f8e6 100644 --- a/07_tempConversion/tempConversion.js +++ b/07_tempConversion/tempConversion.js @@ -1,8 +1,11 @@ -const ftoc = function() { - +const ftoc = function (temp) { + let converted = (temp - 32) * (5 / 9); + return Math.round((converted + Number.EPSILON) * 10) / 10 }; -const ctof = function() { +const ctof = function (temp) { + let converted = temp * (9 / 5) + 32; + return Math.round((converted + Number.EPSILON) * 10) / 10 }; diff --git a/07_tempConversion/tempConversion.spec.js b/07_tempConversion/tempConversion.spec.js index 93679cc..b1b82f2 100644 --- a/07_tempConversion/tempConversion.spec.js +++ b/07_tempConversion/tempConversion.spec.js @@ -4,22 +4,22 @@ describe('ftoc', () => { test('works', () => { expect(ftoc(32)).toEqual(0); }); - test.skip('rounds to 1 decimal', () => { + test('rounds to 1 decimal', () => { expect(ftoc(100)).toEqual(37.8); }); - test.skip('works with negatives', () => { + test('works with negatives', () => { expect(ftoc(-100)).toEqual(-73.3); }); }); describe('ctof', () => { - test.skip('works', () => { + test('works', () => { expect(ctof(0)).toEqual(32); }); - test.skip('rounds to 1 decimal', () => { + test('rounds to 1 decimal', () => { expect(ctof(73.2)).toEqual(163.8); }); - test.skip('works with negatives', () => { + test('works with negatives', () => { expect(ctof(-10)).toEqual(14); }); });