forked from Zelechos/Pragmatic_JavaScript
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathExercise48.js
More file actions
56 lines (47 loc) · 1.38 KB
/
Copy pathExercise48.js
File metadata and controls
56 lines (47 loc) · 1.38 KB
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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
// 48) Crear un objeto con propiedades dinamicas generar links en la web con todas tus redes sociales
// Creamos el objeto
const links = {}
// Creamos unos datos
const dataLinks = [
["https://www.facebook.com/PragmaticCodersGroup","facebook"],
["https://twitter.com/CoderPragmatic","twitter"],
["https://www.instagram.com/pragmatic_coder/","instagram"],
["https://www.linkedin.com/in/alex-tumiri-huanca-6234b3195/","linkedin"]
]
const addLinks = () => {
dataLinks.forEach( link =>{
links[`${link[1]}`] = link[0];
});
return links;
}
const renderLinks = () => {
const object = addLinks();
let content = `
<style>
a{
background-color: green;
border: 1px solid white;
border-radius: 10px;
padding: 5px 10px;
text-decoration: none;
color: black;
font-size: 50px;
}
li{
padding: 10px;
}
</style>
<ul>
`;
for (const key in object) {
let list = `<li>
<a href= "${object[key]}" target="blank">${key}</a>
</li>`;
content += list
}
content += `</ul>`
console.log(content);
// Introducimos nuestro template a el body
document.getElementById("bod").innerHTML = content;
}
renderLinks();