Skip to content

Instantly share code, notes, and snippets.

@parzibyte
Created April 25, 2019 18:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save parzibyte/235667ea69999bc34d2fce9d520c89a2 to your computer and use it in GitHub Desktop.
Save parzibyte/235667ea69999bc34d2fce9d520c89a2 to your computer and use it in GitHub Desktop.
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