tempConversion all done

This commit is contained in:
Mohammed Nabeel 2020-07-18 17:58:27 +03:00
parent 8bc9e3dc90
commit da6a5737cb
2 changed files with 37 additions and 25 deletions

View File

@ -1,8 +1,20 @@
const ftoc = function() {
const ftoc = function(fValue) {
let result = 0.0;
//Convert Farenheit to Celsius
result = Math.round(((fValue - 32) * 5 / 9) * 10) / 10;
return result;
}
const ctof = function() {
const ctof = function(cValue) {
let result = 0.0;
//Convert Celsius to Farenheit
result = Math.round(((cValue * 9 / 5) + 32) * 10) / 10;
return result;
}

View File

@ -1,25 +1,25 @@
const {ftoc, ctof} = require('./tempConversion')
const { ftoc, ctof } = require('./tempConversion')
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);
});
});