From c037ad5bf5814cb7a7275b4163618096a512d527 Mon Sep 17 00:00:00 2001 From: Asartea <76259120+Asartea@users.noreply.github.com> Date: Sat, 12 Nov 2022 20:56:14 +0100 Subject: [PATCH 1/4] Update tempConversion function naming to keep in sync with base branch --- tempConversion/README.md | 4 ++-- tempConversion/tempConversion.js | 10 +++++----- tempConversion/tempConversion.spec.js | 18 +++++++++--------- 3 files changed, 16 insertions(+), 16 deletions(-) diff --git a/tempConversion/README.md b/tempConversion/README.md index 081a650..451535d 100644 --- a/tempConversion/README.md +++ b/tempConversion/README.md @@ -2,9 +2,9 @@ Write two functions that convert temperatures from Fahrenheit to Celsius, and vice versa: ``` -ftoc(32) // fahrenheit to celsius, should return 0 +convertToCelsius(32) // fahrenheit to celsius, should return 0 -ctof(0) // celsius to fahrenheit, should return 32 +convertToFahrenheit(0) // celsius to fahrenheit, should return 32 ``` Because we are human, we want the result temperature to be rounded to one decimal place: i.e., `ftoc(100)` should return `37.8` and not `37.77777777777778`. diff --git a/tempConversion/tempConversion.js b/tempConversion/tempConversion.js index 13430a7..fc526fa 100644 --- a/tempConversion/tempConversion.js +++ b/tempConversion/tempConversion.js @@ -1,13 +1,13 @@ -const ftoc = function(f) { - return Math.round((f - 32) * (5/9) * 10) / 10; +const convertToCelsius = function() { + return Math.round((f - 32) * (5/9) * 10) / 10; }; -const ctof = function(c) { +const convertToFahrenheit = function() { return Math.round(((c * 9/5) + 32) * 10) / 10; }; module.exports = { - ftoc, - ctof + convertToCelsius, + convertToFahrenheit }; diff --git a/tempConversion/tempConversion.spec.js b/tempConversion/tempConversion.spec.js index 93679cc..c4f9742 100644 --- a/tempConversion/tempConversion.spec.js +++ b/tempConversion/tempConversion.spec.js @@ -1,25 +1,25 @@ -const {ftoc, ctof} = require('./tempConversion') +const {convertToCelsius, convertToFahrenheit} = require('./tempConversion') -describe('ftoc', () => { +describe('convertToCelsius', () => { test('works', () => { - expect(ftoc(32)).toEqual(0); + expect(convertToCelsius(32)).toEqual(0); }); test.skip('rounds to 1 decimal', () => { - expect(ftoc(100)).toEqual(37.8); + expect(convertToCelsius(100)).toEqual(37.8); }); test.skip('works with negatives', () => { - expect(ftoc(-100)).toEqual(-73.3); + expect(convertToCelsius(-100)).toEqual(-73.3); }); }); -describe('ctof', () => { +describe('convertToFahrenheit', () => { test.skip('works', () => { - expect(ctof(0)).toEqual(32); + expect(convertToFahrenheit(0)).toEqual(32); }); test.skip('rounds to 1 decimal', () => { - expect(ctof(73.2)).toEqual(163.8); + expect(convertToFahrenheit(73.2)).toEqual(163.8); }); test.skip('works with negatives', () => { - expect(ctof(-10)).toEqual(14); + expect(convertToFahrenheit(-10)).toEqual(14); }); }); From 6bafdb5094c7184a707f6b2592b22de01174bed1 Mon Sep 17 00:00:00 2001 From: Asartea <76259120+Asartea@users.noreply.github.com> Date: Sat, 12 Nov 2022 21:03:08 +0100 Subject: [PATCH 2/4] Accidently got rid of the function parameters --- tempConversion/tempConversion.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/tempConversion/tempConversion.js b/tempConversion/tempConversion.js index fc526fa..dc21f6f 100644 --- a/tempConversion/tempConversion.js +++ b/tempConversion/tempConversion.js @@ -1,9 +1,9 @@ -const convertToCelsius = function() { - return Math.round((f - 32) * (5/9) * 10) / 10; +const convertToCelsius = function(fahrenheit) { + return Math.round((fahrenheit - 32) * (5/9) * 10) / 10; }; -const convertToFahrenheit = function() { - return Math.round(((c * 9/5) + 32) * 10) / 10; +const convertToFahrenheit = function(celsius) { + return Math.round(((celsius * 9/5) + 32) * 10) / 10; }; From e94742d58c5fd20bae760673e05cc3686ca1c174 Mon Sep 17 00:00:00 2001 From: Asartea <76259120+Asartea@users.noreply.github.com> Date: Sat, 12 Nov 2022 21:11:40 +0100 Subject: [PATCH 3/4] Missed another README.md reference --- tempConversion/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tempConversion/README.md b/tempConversion/README.md index 451535d..77682f6 100644 --- a/tempConversion/README.md +++ b/tempConversion/README.md @@ -7,7 +7,7 @@ convertToCelsius(32) // fahrenheit to celsius, should return 0 convertToFahrenheit(0) // celsius to fahrenheit, should return 32 ``` -Because we are human, we want the result temperature to be rounded to one decimal place: i.e., `ftoc(100)` should return `37.8` and not `37.77777777777778`. +Because we are human, we want the result temperature to be rounded to one decimal place: i.e., `convertToCelsius(100)` should return `37.8` and not `37.77777777777778`. This exercise asks you to create more than one function so the `module.exports` section of the spec file looks a little different this time. Nothing to worry about, we're just packaging both functions into a single object to be exported. From 171ac956cfa63804fd8082fffb4db508ced8ea65 Mon Sep 17 00:00:00 2001 From: Asartea <76259120+Asartea@users.noreply.github.com> Date: Sat, 19 Nov 2022 15:09:51 +0100 Subject: [PATCH 4/4] fix spacing --- tempConversion/tempConversion.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tempConversion/tempConversion.js b/tempConversion/tempConversion.js index dc21f6f..4bc3d9d 100644 --- a/tempConversion/tempConversion.js +++ b/tempConversion/tempConversion.js @@ -1,5 +1,5 @@ const convertToCelsius = function(fahrenheit) { - return Math.round((fahrenheit - 32) * (5/9) * 10) / 10; + return Math.round((fahrenheit - 32) * (5/9) * 10) / 10; }; const convertToFahrenheit = function(celsius) {