Last active
October 15, 2016 15:47
-
-
Save esayler/a547e64583848c2f760e71d039816e02 to your computer and use it in GitHub Desktop.
leap-closure.js
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 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; |
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 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