Created
June 17, 2017 06:21
-
-
Save matheustp/fa3c8ebd7455204303bd80de254fa87f to your computer and use it in GitHub Desktop.
Verifica se o ano é bissexto
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
const ehMultiplo = ( multiplo ) => ( ano ) => ano % multiplo === 0 | |
const nao = ( entrada ) => !entrada | |
const ehMultiploDe400 = ehMultiplo( 400 ) | |
const ehMultiploDe4 = ehMultiplo( 4 ) | |
const ehMultiploDe100 = ehMultiplo( 100 ) | |
const ehBissexto = ( ano ) => (ehMultiploDe400( ano ) || (ehMultiploDe4( ano ) && nao(ehMultiploDe100( ano )))) | |
console.log(ehBissexto(2016)) | |
console.log(ehBissexto(1600)) | |
console.log(ehBissexto(2017)) | |
console.log(ehBissexto(2020)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment