From 4b246d17700eba400d34896ed8ebe63ac915a988 Mon Sep 17 00:00:00 2001 From: Andres Garcia Date: Sat, 28 Mar 2020 18:49:21 -0500 Subject: [PATCH] Solution --- tempConversion/tempConversion.js | 10 ++++++---- tempConversion/tempConversion.spec.js | 10 +++++----- 2 files changed, 11 insertions(+), 9 deletions(-) diff --git a/tempConversion/tempConversion.js b/tempConversion/tempConversion.js index 4fa21ee..8a61dc5 100644 --- a/tempConversion/tempConversion.js +++ b/tempConversion/tempConversion.js @@ -1,9 +1,11 @@ -const ftoc = function() { - +const ftoc = function(fahrenheit) { + celsius = (fahrenheit - 32)*(5/9); + return Math.round(celsius* 10)/10; } -const ctof = function() { - +const ctof = function(celsius) { + fahrenheit = celsius * (9/5) + 32; + return Math.round(fahrenheit* 10)/10; } 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); }); });