Completed exercises 05+06
This commit is contained in:
parent
1b6b1674d4
commit
06b4787e5b
|
@ -1,5 +1,5 @@
|
||||||
const helloWorld = function() {
|
const helloWorld = function() {
|
||||||
return ''
|
return 'Hello, World!'
|
||||||
};
|
};
|
||||||
|
|
||||||
module.exports = helloWorld;
|
module.exports = helloWorld;
|
||||||
|
|
|
@ -16,7 +16,7 @@ describe('sumAll', () => {
|
||||||
test('returns ERROR with non-number parameters', () => {
|
test('returns ERROR with non-number parameters', () => {
|
||||||
expect(sumAll(10, "90")).toEqual('ERROR');
|
expect(sumAll(10, "90")).toEqual('ERROR');
|
||||||
});
|
});
|
||||||
test('returns ERROR with non-number parameters', () => {
|
tes('returns ERROR with non-number parameters', () => {
|
||||||
expect(sumAll(10, [90, 1])).toEqual('ERROR');
|
expect(sumAll(10, [90, 1])).toEqual('ERROR');
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
|
@ -1,6 +1,18 @@
|
||||||
const leapYears = function() {
|
const leapYears = function(year) {
|
||||||
|
//
|
||||||
|
//Not Divisible by 100 && /4: leap year
|
||||||
|
//Div by 100 & 400, Y
|
||||||
|
if ( (year%100 != 0) && (year%4 == 0)){
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
else if ((year%100 == 0) && (year%400 == 0)){
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
console.log(leapYears(1997));
|
||||||
// Do not edit below this line
|
// Do not edit below this line
|
||||||
module.exports = leapYears;
|
module.exports = leapYears;
|
||||||
|
|
|
@ -4,19 +4,19 @@ describe('leapYears', () => {
|
||||||
test('works with non century years', () => {
|
test('works with non century years', () => {
|
||||||
expect(leapYears(1996)).toBe(true);
|
expect(leapYears(1996)).toBe(true);
|
||||||
});
|
});
|
||||||
test.skip('works with non century years', () => {
|
test('works with non century years', () => {
|
||||||
expect(leapYears(1997)).toBe(false);
|
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);
|
expect(leapYears(34992)).toBe(true);
|
||||||
});
|
});
|
||||||
test.skip('works with century years', () => {
|
test('works with century years', () => {
|
||||||
expect(leapYears(1900)).toBe(false);
|
expect(leapYears(1900)).toBe(false);
|
||||||
});
|
});
|
||||||
test.skip('works with century years', () => {
|
test('works with century years', () => {
|
||||||
expect(leapYears(1600)).toBe(true);
|
expect(leapYears(1600)).toBe(true);
|
||||||
});
|
});
|
||||||
test.skip('works with century years', () => {
|
test('works with century years', () => {
|
||||||
expect(leapYears(700)).toBe(false);
|
expect(leapYears(700)).toBe(false);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue