-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtesting.js
More file actions
37 lines (32 loc) · 1.06 KB
/
testing.js
File metadata and controls
37 lines (32 loc) · 1.06 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
// Create new set of random columns indefinitely
let firstTime = true;
function makeColumn (num) {
for (let i = 0; i < num; i++) {
let column = document.createElement('div');
column.classList.add('column');
column.style.background = 'brown';
// Here's how we style the DOM elements
column.style.height = getRandomInt(columnMinHeight, columnMaxHeight) + 'px';
createColumns.appendChild(column);
}
}
function makeGrid(numCols) {
createColumns.style.setProperty('--numCols', numCols);
}
createColumnsButton.addEventListener('click', () => {
if (firstTime) {
makeColumn(numberOfColumns);
makeGrid(numberOfColumns);
firstTime = false;
}
else {
for (let i = 0; i < numberOfColumns; i++) {
// Helpful link: https://stackoverflow.com/questions/3955229/remove-all-child-elements-of-a-dom-node-in-javascript
while (createColumns.firstChild) {
createColumns.removeChild(createColumns.lastChild);
}
}
makeColumn(numberOfColumns);
makeGrid(numberOfColumns);
}
})