-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfunction_storage.js
More file actions
43 lines (33 loc) · 1.02 KB
/
function_storage.js
File metadata and controls
43 lines (33 loc) · 1.02 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
export { shuffle };
function clickCount(i, elem) {
if ((String(i).at(-1) === '2' || String(i).at(-1) === '3' || String(i).at(-1) === '4') &&
String(i).at(-2) !== '1') {
elem.innerHTML = `(Нажато ${i} раза)`;
} else {
elem.innerHTML = `(Нажато ${i} раз)`;
}
}
function shuffle(array) {
for (let i = array.length - 1; i > 0; i--) {
let j = Math.floor(Math.random() * (i + 1));
[array[i], array[j]] = [array[j], array[i]];
}
return array;
}
function randomNumber(min, max) {
return min + Math.random() * (max - min);
}
function randomInteger(min, max) {
let random = min + Math.random() * (max + 1 - min);
return Math.floor(random);
}
function scrollWidth() {
let div = document.createElement('div');
div.style.overflowY = 'scroll';
div.style.width = '50px';
div.style.height = '50px';
document.body.append(div);
let scrollWidth = div.offsetWidth - div.clientWidth;
div.remove();
return scrollWidth;
}