diff --git a/src/app.js b/src/app.js index f129d1c9e..33126830c 100644 --- a/src/app.js +++ b/src/app.js @@ -5,7 +5,36 @@ import "./style.css"; import "./assets/img/rigo-baby.jpg"; import "./assets/img/4geeks.ico"; +import Excusa from "./excusa.js"; +import gr from "./getRandom"; + window.onload = function() { //write your code here - console.log("Hello Rigo from the console!"); + + let quien = [ + "Darwin Nuñez", + "Mi perro Toto", + "El vecino", + "Joaquito de Piedras Blancas" + ]; + let accion = ["le erró a", "meó", "me robó", "me pegó con"]; + let que = ["la pelota", "el sillón", "mi gato", "la alpargata"]; + let cuando = [ + "durante la clase", + "otra vez", + "mientras cargaba el codespace💤" + ]; + + let botonGenerarExcusa = document.querySelector("#botonGenerar"); + let contenedorExcusa = document.querySelector("code"); + let botonCopiar = document.querySelector("#botonCopiar"); + + botonGenerarExcusa.addEventListener("click", function(e) { + let excusa = new Excusa(gr(quien), gr(accion), gr(que), gr(cuando)); + contenedorExcusa.innerHTML = excusa.getExcusa(); + }); + + botonCopiar.addEventListener("click", function(e) { + navigator.clipboard.writeText(contenedorExcusa.innerText); + }); }; diff --git a/src/excusa.js b/src/excusa.js new file mode 100644 index 000000000..14d89c220 --- /dev/null +++ b/src/excusa.js @@ -0,0 +1,12 @@ +export default class Excusa { + constructor(quien, accion, que, cuando) { + this.quien = quien; + this.accion = accion; + this.que = que; + this.cuando = cuando; + } + + getExcusa() { + return `${this.quien} ${this.accion} ${this.que} ${this.cuando}`; + } +} diff --git a/src/getRandom.js b/src/getRandom.js new file mode 100644 index 000000000..f14344836 --- /dev/null +++ b/src/getRandom.js @@ -0,0 +1,3 @@ +export default function getRandom(array) { + return array[Math.floor(Math.random() * array.length)]; +} diff --git a/src/index.html b/src/index.html index e275741cf..ef2684846 100644 --- a/src/index.html +++ b/src/index.html @@ -3,7 +3,7 @@
-- If this text is not centered and yellow, you probably have - an error -
-
+ Mentir está mal pero si querés podés cliquear el dado
+
+
+
+