Completed leapYears and tempConversion exercises
This commit is contained in:
parent
f7aa76e904
commit
242936c046
|
@ -1,5 +1,14 @@
|
|||
const leapYears = function() {
|
||||
|
||||
const leapYears = function(year) {
|
||||
if (year % 4 == 0) {
|
||||
if (year % 100 == 0) {
|
||||
if (year % 400 == 0) {
|
||||
return true
|
||||
}
|
||||
return false
|
||||
}
|
||||
return true
|
||||
}
|
||||
return false
|
||||
};
|
||||
|
||||
// Do not edit below this line
|
||||
|
|
|
@ -4,19 +4,19 @@ describe('leapYears', () => {
|
|||
test('works with non century years', () => {
|
||||
expect(leapYears(1996)).toBe(true);
|
||||
});
|
||||
test.skip('works with non century years', () => {
|
||||
test('works with non century years', () => {
|
||||
expect(leapYears(1997)).toBe(false);
|
||||
});
|
||||
test.skip('works with ridiculously futuristic non century years', () => {
|
||||
test('works with ridiculously futuristic non century years', () => {
|
||||
expect(leapYears(34992)).toBe(true);
|
||||
});
|
||||
test.skip('works with century years', () => {
|
||||
test('works with century years', () => {
|
||||
expect(leapYears(1900)).toBe(false);
|
||||
});
|
||||
test.skip('works with century years', () => {
|
||||
test('works with century years', () => {
|
||||
expect(leapYears(1600)).toBe(true);
|
||||
});
|
||||
test.skip('works with century years', () => {
|
||||
test('works with century years', () => {
|
||||
expect(leapYears(700)).toBe(false);
|
||||
});
|
||||
});
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
const ftoc = function() {
|
||||
|
||||
const ftoc = function(fTemp) {
|
||||
return Number(((fTemp - 32) * (5 / 9)).toFixed(1))
|
||||
};
|
||||
|
||||
const ctof = function() {
|
||||
|
||||
const ctof = function(cTemp) {
|
||||
return Number(((cTemp * (9 / 5)) + 32).toFixed(1))
|
||||
};
|
||||
|
||||
// Do not edit below this line
|
||||
|
|
|
@ -4,22 +4,22 @@ describe('ftoc', () => {
|
|||
test('works', () => {
|
||||
expect(ftoc(32)).toEqual(0);
|
||||
});
|
||||
test.skip('rounds to 1 decimal', () => {
|
||||
test('rounds to 1 decimal', () => {
|
||||
expect(ftoc(100)).toEqual(37.8);
|
||||
});
|
||||
test.skip('works with negatives', () => {
|
||||
test('works with negatives', () => {
|
||||
expect(ftoc(-100)).toEqual(-73.3);
|
||||
});
|
||||
});
|
||||
|
||||
describe('ctof', () => {
|
||||
test.skip('works', () => {
|
||||
test('works', () => {
|
||||
expect(ctof(0)).toEqual(32);
|
||||
});
|
||||
test.skip('rounds to 1 decimal', () => {
|
||||
test('rounds to 1 decimal', () => {
|
||||
expect(ctof(73.2)).toEqual(163.8);
|
||||
});
|
||||
test.skip('works with negatives', () => {
|
||||
test('works with negatives', () => {
|
||||
expect(ctof(-10)).toEqual(14);
|
||||
});
|
||||
});
|
||||
|
|
Loading…
Reference in New Issue