Wrote solution to tempConversion exercise

This commit is contained in:
Kira 2018-08-27 18:35:29 +00:00
parent 1b8d812b78
commit 3bbe72b2c0
3 changed files with 13 additions and 19 deletions

View File

@ -1,13 +1,5 @@
const leapYears = function(date) { const leapYears = function(year) {
if (date % 4 === 0) { return year % 4 === 0 && (year % 100 !== 0 || year % 400 == 0)
if (date % 100 === 0 && date % 400 !== 0) {
return false;
} else {
return true;
}
} else {
return false;
}
} }
module.exports = leapYears module.exports = leapYears

View File

@ -1,9 +1,11 @@
const ftoc = function() { const ftoc = function(tempInF) {
let tempInC = (tempInF - 32) * 5/9;
return Math.round(tempInC * 10) / 10;
} }
const ctof = function() { const ctof = function(tempInC) {
let tempInF = tempInC * 9/5 + 32;
return Math.round(tempInF * 10) / 10;
} }
module.exports = { module.exports = {

View File

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