-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
39 lines (30 loc) · 900 Bytes
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
const crudList = (listaInicial = []) => {
let listaInterna = listaInicial;
const obtenerLista = () => listaInterna;
const agregarALista = (nuevo) => {
listaInterna = [...listaInterna, nuevo]
}
return Object.freeze({
obtenerLista,
agregarALista
})
}
const perroList = crudList();
const imagenPerro = () => {
return document.getElementById("imagenPerro").value;
}
const agregarPerro = document.getElementById("agregarPerro").addEventListener("click", () => {
const imagenDelPerro = imagenPerro()
perroList.agregarALista(imagenDelPerro);
render();
})
const render = () => {
let htmlConImagenes = ''
perroList.obtenerLista().forEach((perro) => {
htmlConImagenes += `
<img src="${perro}" />
`
})
const contenedor = document.getElementById("contenedor");
contenedor.innerHTML = htmlConImagenes;
}