Skip to content

Instantly share code, notes, and snippets.

@esayler
Last active October 15, 2016 15:47
Show Gist options
  • Save esayler/a547e64583848c2f760e71d039816e02 to your computer and use it in GitHub Desktop.
Save esayler/a547e64583848c2f760e71d039816e02 to your computer and use it in GitHub Desktop.
leap-closure.js
var Year = function(input) {
Year.prototype.isLeap = function() {
if (input % 4 === 0) {
if (input % 100 === 0) {
if (input % 400 === 0) {
return true;
} else {
return false;
}
} else {
return true;
}
} else {
return false;
}
}
};
module.exports = Year;
var Year = function(input) {
this.input = input;
this.isLeap = function () {
var divByFour = input % 4 === 0;
var divByOneHundred = input % 100 === 0;
var divByFourHundred = input % 400 == 0;
return (divByFour && divByOneHundred && divByFourHundred) ||
(divByFour && !divByOneHundred);
};
//Year.prototype.isLeap = function() {
//};
module.exports = Year;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment