Created
September 16, 2016 15:25
-
-
Save jasonkarns/062a32bc1aea304b208226c47b042e38 to your computer and use it in GitHub Desktop.
This file contains 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
module.exports = function findMaxValidDate(min, max) { | |
var next = Math.floor((min+max)/2); | |
if(min == next) return min; | |
if(new Date(next) == "Invalid Date") { | |
return findMaxValidDate(min, next); | |
} else { | |
return findMaxValidDate(next, max); | |
} | |
} | |
console.log(module.exports(0, Number.MAX_VALUE)); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment