From 4cb2fa66b9d773b656f5827c4fdd85dc99006a20 Mon Sep 17 00:00:00 2001 From: NetMan <13informatyka14@gmail.com> Date: Fri, 5 Jan 2024 22:08:37 +0100 Subject: [PATCH] Passes all tests from toFahrenheit in exercise 07 in conclusion passes all tests! --- 07_tempConversion/tempConversion.js | 3 ++- 07_tempConversion/tempConversion.spec.js | 6 +++--- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/07_tempConversion/tempConversion.js b/07_tempConversion/tempConversion.js index ebc51d9..73aadaa 100644 --- a/07_tempConversion/tempConversion.js +++ b/07_tempConversion/tempConversion.js @@ -2,7 +2,8 @@ const convertToCelsius = function(deg) { return Math.round((deg - 32) * (5/9) * 10) / 10; }; -const convertToFahrenheit = function() { +const convertToFahrenheit = function(deg) { + return Math.round((deg * (9/5) + 32) * 10) / 10; // x °C ≘ (x ×9/5+ 32) °F }; diff --git a/07_tempConversion/tempConversion.spec.js b/07_tempConversion/tempConversion.spec.js index 8bbd385..7d0cc93 100644 --- a/07_tempConversion/tempConversion.spec.js +++ b/07_tempConversion/tempConversion.spec.js @@ -13,13 +13,13 @@ describe('convertToCelsius', () => { }); 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); }); });