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

Function generatearray

assets/js/bucketsort.js:15–50  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

13}
14
15function generatearray() {
16
17// Creating an array
18var arr = [];
19
20// Filling array with values from 1 to 20
21for (var i = 0; i < 20; i++) {
22 arr.push(i + 1);
23}
24
25// Shuffling the array
26shuffle(arr);
27for (var i = 0; i < 20; i++) {
28 var value = arr[i];
29
30 // Creating element div
31 var array_ele = document.createElement("div");
32
33 // Adding class 'block' to div
34 array_ele.classList.add("block");
35
36 // Adding style to div
37 array_ele.style.height = `${value * 11}px`;
38 array_ele.style.transform = `translate(${i * 30}px)`;
39
40 // Creating label element for displaying
41 // size of particular block
42 var array_ele_label = document.createElement("label");
43 array_ele_label.classList.add("block_id");
44 array_ele_label.innerText = value;
45
46 // Appending created elements to index.html
47 array_ele.appendChild(array_ele_label);
48 container.appendChild(array_ele);
49}
50}
51
52async function InsertionSort(clsnam, delay = 600) {
53let blocks = document.getElementsByClassName(clsnam);

Callers 1

bucketsort.jsFile · 0.70

Calls 1

shuffleFunction · 0.70

Tested by

no test coverage detected