-
-
Save parzibyte/235667ea69999bc34d2fce9d520c89a2 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
const cantidadDeDiasDesafortunados = anio => { | |
let fecha = new Date(anio, 0), | |
contador = 0; | |
// Hacer un ciclo desde enero hasta diciembre | |
for (let monthNumber = 0; monthNumber < 12; monthNumber++) { | |
fecha.setMonth(monthNumber); | |
// Ir al día 13 de ese mes | |
fecha.setDate(13); | |
// Y comprobar si es viernes | |
if (fecha.getDay() === 5) contador++; | |
} | |
return contador; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment