-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathscripts.js
70 lines (66 loc) · 1.62 KB
/
scripts.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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
const sectionContacts = document.querySelector(".contacts")
const contacts = [
[
"A",
"purple",
[
{ nome: "Alfredo", sexo: "men" },
{ nome: "Angelina", sexo: "women" },
],
],
[
"B",
"green",
[
{ nome: "Bia", sexo: "women" },
{ nome: "Belinda", sexo: "women" },
{ nome: "Bruno", sexo: "men" },
],
],
[
"C",
"pink",
[
{ nome: "Carlos", sexo: "men" },
{ nome: "Carla", sexo: "women" },
{ nome: "Caio", sexo: "men" },
],
],
[
"D",
"blue",
[
{ nome: "Denny", sexo: "men" },
{ nome: "Daniel", sexo: "men" },
{ nome: "Diogo", sexo: "men" },
],
],
["E", "yellow", [{ nome: "Elaine", sexo: "women" }]],
]
let changePhoto = 1
for (let iOfLetter = 0; iOfLetter < contacts.length; iOfLetter++) {
sectionContacts.innerHTML +=
`
<div class="list-wrapper flex">
<div class="letter ${contacts[iOfLetter][1]}">${contacts[iOfLetter][0]}</div>
<ul>
</ul>
</div>
`
const personContacts = document.querySelectorAll(`.contacts ul`)[iOfLetter]
for (let jOfNames = 0; jOfNames < contacts[iOfLetter][2].length; jOfNames++) {
changePhoto++
personContacts.innerHTML +=
`
<li>
<div class="person flex">
<img src="https://randomuser.me/api/portraits/${contacts[iOfLetter][2][jOfNames].sexo}/${changePhoto}.jpg" alt="" />
<div class="contact">
<h3>${contacts[iOfLetter][2][jOfNames].nome}</h3>
<p>(11) 90913-1234</p>
</div>
</div>
</li>
`
}
}