Skip to content

Instantly share code, notes, and snippets.

@trys
Created October 27, 2015 23:20
Show Gist options
  • Save trys/147a76bc7ebec4ce5f07 to your computer and use it in GitHub Desktop.
Save trys/147a76bc7ebec4ce5f07 to your computer and use it in GitHub Desktop.
Problem Nineteen
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