From 62bdc6029e8a8bf300a7fb7fbbc9a327bede07d3 Mon Sep 17 00:00:00 2001 From: Othamae Date: Thu, 29 Jun 2023 15:43:17 +0200 Subject: [PATCH] Reto #12 - javascript --- .../javascript/othamae.js" | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 "Retos/Reto #12 - VIERNES 13 [F\303\241cil]/javascript/othamae.js" diff --git "a/Retos/Reto #12 - VIERNES 13 [F\303\241cil]/javascript/othamae.js" "b/Retos/Reto #12 - VIERNES 13 [F\303\241cil]/javascript/othamae.js" new file mode 100644 index 0000000000..e415b2491e --- /dev/null +++ "b/Retos/Reto #12 - VIERNES 13 [F\303\241cil]/javascript/othamae.js" @@ -0,0 +1,15 @@ +/* + * Crea una función que sea capaz de detectar si existe un viernes 13 en el mes y el año indicados. + * - La función recibirá el mes y el año y retornará verdadero o falso. + */ + +const isFriday13th = (month, year) => { + const date = new Date(year, month - 1, 13); + return date.getDay() === 5; +} + +console.log(isFriday13th(5, 2020)); +console.log(isFriday13th(10, 2021)); +console.log(isFriday13th(5, 2022)); +console.log(isFriday13th(7, 2023)); +console.log(isFriday13th(6, 2024));