07 solution

This commit is contained in:
LoptrSir 2022-03-15 11:05:02 -07:00
parent a07441c9d3
commit ae2ab746be
2 changed files with 19 additions and 11 deletions

View File

@ -1,13 +1,21 @@
const ftoc = function() { const ftoc = function(f) {
let cel = (f - 32) * 5 / 9;
cel = cel.toFixed(1);
console.log(parseFloat(cel));
return parseFloat(cel);
}; };
const ctof = function() { const ctof = function(c) {
let faren = c * 9 / 5 + 32;
faren = faren.toFixed(1);
console.log(parseFloat(faren));
return parseFloat(faren);
}; };
ftoc(-21);
ctof(-10);
// Do not edit below this line // Do not edit below this line
module.exports = { module.exports = {
ftoc, ftoc,
ctof ctof
}; };

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);
}); });
}); });