-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathnodejs.txt
More file actions
74 lines (57 loc) · 1.66 KB
/
nodejs.txt
File metadata and controls
74 lines (57 loc) · 1.66 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
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
let n = Math.floor(Math.random() * 10) ;
let counterValue = n;
let baseMarginLeft = 49;
let array_container = document.createElement('div');
array_container.className="array_container";
array_container.id="array_container";
document.getElementById("container").appendChild(array_container);
function createSpan(n)
{
let counter = document.getElementById("counterValue");
counter.innerText = n;
let baseHeight = 4;
let base_width = 40;
if(counterValue>18 && counterValue<24)
{
base_width -=10;
}
if(counterValue>23 && counterValue<=34)
{
base_width -=20;
}
if(counterValue>34 && counterValue<=60)
{
base_width -=30;
}
for(let i = 0;i<n;i++)
{
let rndmarr = Math.floor(Math.random() * 100) + 1;
let div = document.createElement("div");
// div.style.padding = "10px";
div.className="array_div";
div.style.border="1px solid red";
div.style.backgroundColor = "black";
div.style.color="white";
div.style.width=base_width+'px';
div.style.height= (rndmarr*baseHeight)+'px';
div.style.position = "relative";
if(n<35){
div.innerHTML="<span>"+rndmarr+"</span>"; }
let array_div = document.getElementById("array_container");
array_div.appendChild(div);
console.log(div);
}
}
function counterChange(n)
{
if(n==1 && counterValue<60)
{
counterValue++;
}
else if(n==-1 && counterValue>2){
counterValue--;
}
while (array_container.firstChild) array_container.removeChild(array_container.firstChild);
createSpan(counterValue);
}
createSpan(n);