Fix Euler Project problem 19
This commit is contained in:
committed by
Kristofer Koishigawa
parent
955fc19e35
commit
3f328b73dc
@ -23,8 +23,8 @@ How many Sundays fell on the first of the month during the twentieth century (1
|
||||
tests:
|
||||
- text: '<code>countingSundays(1943, 1946)</code> should return 6.'
|
||||
testString: 'assert.strictEqual(countingSundays(1943, 1946), 6, "<code>countingSundays(1943, 1946)</code> should return 6.");'
|
||||
- text: '<code>countingSundays(1995, 2000)</code> should return 9.'
|
||||
testString: 'assert.strictEqual(countingSundays(1995, 2000), 9, "<code>countingSundays(1995, 2000)</code> should return 9.");'
|
||||
- text: '<code>countingSundays(1995, 2000)</code> should return 10.'
|
||||
testString: 'assert.strictEqual(countingSundays(1995, 2000), 10, "<code>countingSundays(1995, 2000)</code> should return 10.");'
|
||||
- text: '<code>countingSundays(1901, 2000)</code> should return 171.'
|
||||
testString: 'assert.strictEqual(countingSundays(1901, 2000), 171, "<code>countingSundays(1901, 2000)</code> should return 171.");'
|
||||
|
||||
@ -61,7 +61,7 @@ function countingSundays(firstYear, lastYear) {
|
||||
let sundays = 0;
|
||||
|
||||
for (let year = firstYear; year <= lastYear; year++) {
|
||||
for (let month = 1; month <= 12; month++) {
|
||||
for (let month = 0; month <= 11; month++) {
|
||||
const thisDate = new Date(year, month, 1);
|
||||
if (thisDate.getDay() === 0) {
|
||||
sundays++;
|
||||
|
Reference in New Issue
Block a user