From 3b9c8b9515fe872a070cbc89db24583f555f7a2b Mon Sep 17 00:00:00 2001 From: Nidhish1407 Date: Thu, 27 Aug 2020 18:07:42 +0530 Subject: [PATCH] Added solution for tempConversion --- tempConversion/tempConversion.js | 12 ++++++++---- tempConversion/tempConversion.spec.js | 10 +++++----- 2 files changed, 13 insertions(+), 9 deletions(-) diff --git a/tempConversion/tempConversion.js b/tempConversion/tempConversion.js index 4fa21ee..f9491d6 100644 --- a/tempConversion/tempConversion.js +++ b/tempConversion/tempConversion.js @@ -1,9 +1,13 @@ -const ftoc = function() { - +const ftoc = function(f) { + let c = (f-32)*(5/9); + let celcius = +c.toFixed(1); + return celcius; } -const ctof = function() { - +const ctof = function(c) { + let f = c * (9/5) + 32; + let fahrenheit = +f.toFixed(1); + return fahrenheit; } module.exports = { diff --git a/tempConversion/tempConversion.spec.js b/tempConversion/tempConversion.spec.js index 0dc9168..bdb7c0e 100644 --- a/tempConversion/tempConversion.spec.js +++ b/tempConversion/tempConversion.spec.js @@ -4,22 +4,22 @@ describe('ftoc', function() { it('works', function() { expect(ftoc(32)).toEqual(0); }); - xit('rounds to 1 decimal', function() { + it('rounds to 1 decimal', function() { expect(ftoc(100)).toEqual(37.8); }); - xit('works with negatives', function() { + it('works with negatives', function() { expect(ftoc(-100)).toEqual(-73.3); }); }); describe('ctof', function() { - xit('works', function() { + it('works', function() { expect(ctof(0)).toEqual(32); }); - xit('rounds to 1 decimal', function() { + it('rounds to 1 decimal', function() { expect(ctof(73.2)).toEqual(163.8); }); - xit('works with negatives', function() { + it('works with negatives', function() { expect(ctof(-10)).toEqual(14); }); });