-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
86 lines (79 loc) · 1.81 KB
/
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
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
// Import stylesheets
import './style.css';
// Write Javascript code!
const appDiv = document.getElementById('app');
appDiv.innerHTML = `<h1>JS STARTER</h1>`;
const a = [
1,
2,
3,
-1,
0,
-1,
-1,
-1,
3333,
-800000123,
17,
0,
0,
1.222,
18,
22,
4,
1,
2,
0,
456,
3,
-5,
6,
8,
9
];
function createTable() {
const table = document.createElement('table');
table.style.width = '40%';
table.style.textAlign = 'center';
table.style.position = 'absolute';
table.style.background = '#dee2e6';
table.style.margin = '15px';
table.setAttribute('border', '1px');
const head = table.createTHead();
head.appendChild(document.createTextNode('TABLE'));
for (let j = 0; j < a.length / 2; j++) {
const row = head.insertRow();
for (let i = 0; i < 2; i++) {
const tableCell = row.insertCell();
tableCell.style.padding = '10px';
tableCell.style.background = 'white';
tableCell.setAttribute('rowSpan', '1');
let item = a[j * 2 + i];
tableCell.appendChild(document.createTextNode(item));
}
}
document.body.append(table);
}
createTable();
const parent = document.createElement('div');
document.body.append(parent);
parent.innerHTML = 'DIVs';
parent.style.position = 'absolute';
parent.style.padding = '10px';
parent.style.right = '5%';
parent.style.margin = '10px';
parent.style.width = '40vw';
parent.style.display = 'grid';
parent.style.gridTemplateColumns = 'repeat(2, minmax(50px, 1fr)';
parent.style.gridGap = '30px';
for (let k = 0; k < a.length; k++) {
const box = document.createElement('div');
parent.append(box);
box.style.width = '100px';
box.style.height = '20px';
box.style.background = '#dee2e6';
box.style.position = 'relative';
box.style.textAlign = 'center';
box.style.padding = '15px';
box.innerHTML = a[k];
}