From 08d14383b0ebb0075c15ee72d28f065f94f7ec56 Mon Sep 17 00:00:00 2001 From: NetMan <13informatyka14@gmail.com> Date: Fri, 5 Jan 2024 22:06:28 +0100 Subject: [PATCH] Passed tests 2 & 3 toCelsius from exercise 07 added Math.round essentially multiplying inside of round, and dividing out of it will increase the rounding decimal point --- 07_tempConversion/tempConversion.js | 2 +- 07_tempConversion/tempConversion.spec.js | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/07_tempConversion/tempConversion.js b/07_tempConversion/tempConversion.js index abea34c..ebc51d9 100644 --- a/07_tempConversion/tempConversion.js +++ b/07_tempConversion/tempConversion.js @@ -1,5 +1,5 @@ const convertToCelsius = function(deg) { - return (deg - 32) * (5/9); + return Math.round((deg - 32) * (5/9) * 10) / 10; }; const convertToFahrenheit = function() { diff --git a/07_tempConversion/tempConversion.spec.js b/07_tempConversion/tempConversion.spec.js index c4f9742..8bbd385 100644 --- a/07_tempConversion/tempConversion.spec.js +++ b/07_tempConversion/tempConversion.spec.js @@ -4,10 +4,10 @@ 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); }); });