Wrote solution to tempConversion exercise
This commit is contained in:
parent
1b8d812b78
commit
3bbe72b2c0
|
@ -1,13 +1,5 @@
|
|||
const leapYears = function(date) {
|
||||
if (date % 4 === 0) {
|
||||
if (date % 100 === 0 && date % 400 !== 0) {
|
||||
return false;
|
||||
} else {
|
||||
return true;
|
||||
}
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
const leapYears = function(year) {
|
||||
return year % 4 === 0 && (year % 100 !== 0 || year % 400 == 0)
|
||||
}
|
||||
|
||||
module.exports = leapYears
|
||||
|
|
|
@ -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 = {
|
||||
|
|
|
@ -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);
|
||||
});
|
||||
});
|
||||
|
|
Loading…
Reference in New Issue