diff --git a/clase-9.js b/clase-9.js index 6df1007..26ff756 100644 --- a/clase-9.js +++ b/clase-9.js @@ -1 +1,32 @@ // Agregar acá el código javascript para los ejercicios + +/* + +1. Agregar a la página un botón y un párrafo que diga `Botón clickeado 0 + veces`. Cada vez que se haga clic en el botón, el texto del párrafo debe + cambiar al mensaje `"Botón clickeado N veces"`, donde N es el número de + veces que se hizo clic. + +*/ + +const boton = document.getElementById("boton"); + +boton.addEventListener("click", () => { + + let contador = parseInt(document.getElementById("cantidad").textContent); + + contador = contador + 1; + + document.getElementById("cantidad").textContent = contador; + + if (contador === 1) { + + document.getElementById("descripcionCantidad").textContent = "vez."; + + } else { + + document.getElementById("descripcionCantidad").textContent = "veces."; + + } + +}) \ No newline at end of file diff --git a/index.html b/index.html index 2a6b85f..8abeff5 100644 --- a/index.html +++ b/index.html @@ -9,7 +9,8 @@

Clase 9 - Eventos

- +

Boton clickeado 0 veces.

+