solved 07

This commit is contained in:
Mateusz Bujak 2022-07-23 14:20:28 +02:00
parent 998f992b8f
commit 4ff7b6611f
2 changed files with 11 additions and 8 deletions

View File

@ -1,8 +1,11 @@
const ftoc = function() { const ftoc = function (temp) {
let converted = (temp - 32) * (5 / 9);
return Math.round((converted + Number.EPSILON) * 10) / 10
}; };
const ctof = function() { const ctof = function (temp) {
let converted = temp * (9 / 5) + 32;
return Math.round((converted + Number.EPSILON) * 10) / 10
}; };

View File

@ -4,22 +4,22 @@ describe('ftoc', () => {
test('works', () => { test('works', () => {
expect(ftoc(32)).toEqual(0); expect(ftoc(32)).toEqual(0);
}); });
test.skip('rounds to 1 decimal', () => { test('rounds to 1 decimal', () => {
expect(ftoc(100)).toEqual(37.8); expect(ftoc(100)).toEqual(37.8);
}); });
test.skip('works with negatives', () => { test('works with negatives', () => {
expect(ftoc(-100)).toEqual(-73.3); expect(ftoc(-100)).toEqual(-73.3);
}); });
}); });
describe('ctof', () => { describe('ctof', () => {
test.skip('works', () => { test('works', () => {
expect(ctof(0)).toEqual(32); expect(ctof(0)).toEqual(32);
}); });
test.skip('rounds to 1 decimal', () => { test('rounds to 1 decimal', () => {
expect(ctof(73.2)).toEqual(163.8); expect(ctof(73.2)).toEqual(163.8);
}); });
test.skip('works with negatives', () => { test('works with negatives', () => {
expect(ctof(-10)).toEqual(14); expect(ctof(-10)).toEqual(14);
}); });
}); });