-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathSpindler_Exercise13.html
104 lines (93 loc) · 2.58 KB
/
Spindler_Exercise13.html
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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
<!DOCTYPE html>
<html>
<head>
<title>Lab #13</title>
</head>
<body>
<h3>Employee's</h3>
<div id="all">
<table class="table">
<thead>
<tr>
<th>
Name
</th>
<th>
Birthday
</th>
<th>
Languages
</th>
</tr>
</thead>
<tbody id="table">
</tbody>
</table>
</div>
<script>
var userList = {
"people": [
{
firstName: "Fred", lastName: "Smith", dateOfBirth: 1980, spokenLanguages: {
native: "English",
fluent: "Spanish", intermediate: "Chinese"
}
},
{
firstName: "Monica",
lastName: "Taylor", dateOfBirth: 1975, spokenLanguages: {
native: "Spanish", fluent: "English", intermediate: "French"
}
},
{
firstName: "Maurice",
lastName: "Edelson", dateOfBirth: 1992, spokenLanguages: {
native: "English", fluent: "Spanish",
}
},
{
firstName: "Kelly",
lastName: "Lang", dateOfBirth: 1982, spokenLanguages: {
native: "English", fluent: "German", intermediate: "Dutch"
}
}]
};
let table = document.getElementById('table')
userList.people.forEach(worker => {
let {firstName, lastName, dateOfBirth, spokenLanguages} = worker
let {native, fluent, intermediate} = spokenLanguages
let tr = document.createElement('tr')
let tdName = document.createElement('td')
let tdBirth = document.createElement('td')
let tdLang = document.createElement('td')
tdName.innerText = firstName + ' ' + lastName
tdBirth.innerText = dateOfBirth
tdLang.innerText = `${native} ${fluent} ${intermediate}`
tr.append(tdName)
tr.append(tdBirth)
tr.append(tdLang)
table.append(tr)
})
</script>
</body>
<style>
.table {
font-family: Arial, Helvetica, sans-serif;
border-collapse: collapse;
width: 100%;
}
.table td, .table th {
border: 1px solid #ddd;
padding: 8px;
}
.table tr:nth-child(even){background-color: #f2f2f2;}
.table tr:hover {background-color: #ddd;}
.table th {
padding-top: 12px;
padding-bottom: 12px;
text-align: left;
background-color: darkgreen;
color: white;
}
</style>
</html>