MCPcopy Create free account
hub / github.com/Vishal-raj-1/Awesome-JavaScript-Projects / generatearray

Function generatearray

assets/js/heapsort.js:4–30  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

2
3// Function to generate the array of blocks
4function generatearray() {
5for (var i = 0; i < 20; i++) {
6
7 // Return a value from 1 to 100 (both inclusive)
8 var value = Math.ceil(Math.random() * 100);
9
10 // Creating element div
11 var array_ele = document.createElement("div");
12
13 // Adding class 'block' to div
14 array_ele.classList.add("block");
15
16 // Adding style to div
17 array_ele.style.height = `${value * 3}px`;
18 array_ele.style.transform = `translate(${i * 30}px)`;
19
20 // Creating label element for displaying
21 // size of particular block
22 var array_ele_label = document.createElement("label");
23 array_ele_label.classList.add("block_id");
24 array_ele_label.innerText = value;
25
26 // Appending created elements to index.html
27 array_ele.appendChild(array_ele_label);
28 container.appendChild(array_ele);
29}
30}
31
32// Function to generate the indexes
33var count_container = document.getElementById("count");

Callers 1

heapsort.jsFile · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected