-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy path25_TableOfProperty.js
49 lines (37 loc) · 1020 Bytes
/
25_TableOfProperty.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
'use strict';
const profile = {
isAdmin: true,
age: 28,
nickname: 'iketari',
avatar: 'http://i.imgur.com/FHMnsVNt.jpg'
};
/**
* выводит объект profile в таблицу
* @return {Element}
*/
function printProfile() {
let div = document.createElement('div');
div.innerHTML = `
<table class="table table-hover table-mc-light-blue">
<thead>
<tr>
<th>Key</th>
<th>Value</th>
</tr>
</thead>
<tbody></tbody>
</table>`;
let tbody = div.querySelector('tbody');
for (let key in profile) {
let row = document.createElement('tr');
let cellKey = document.createElement('td');
let cellValue = document.createElement('td');
cellKey.textContent = key;
row.appendChild(cellKey);
cellValue.textContent = profile[key];
row.appendChild(cellValue);
tbody.appendChild(row);
}
return div;
}
document.body.append(printProfile());