Created
October 27, 2015 23:20
-
-
Save trys/147a76bc7ebec4ce5f07 to your computer and use it in GitHub Desktop.
Problem Nineteen
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var date, | |
counter = 0; | |
for (var i = 1901; i <= 2000; i++) { | |
for (var j = 1; j <= 12; j++) { | |
date = new Date( i + '-' + pad( j ) + '-01' ); | |
if ( date.getDay() === 0 ) { | |
counter++; | |
} | |
} | |
} | |
function pad( string ) { | |
string += ''; | |
if ( string.length === 1 ) { | |
string = '0' + string; | |
} | |
return string; | |
} | |
document.write( counter ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment