-
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathapp.js
38 lines (31 loc) · 877 Bytes
/
app.js
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
const count = 75;
const getRandomInt = (min, max) => {
min = Math.ceil(min);
max = Math.floor(max);
return Math.floor(Math.random() * (max - min)) + min;
};
let current = 0;
let numbers = Array.from(Array(count), (v, k) => k + 1);
$("#next").click(() => {
if (numbers.length <= 0) {
$("#now").text("Fin.");
$("#next")
.attr("disabled", true)
.text("Reload to reset");
return;
}
const rand = numbers[getRandomInt(0, numbers.length)];
console.log(rand);
$("#next").text("Next");
$("#now").text(rand);
$("#counter").text(++current + " of " + count);
$("#histories")
.append(
$("<span>")
.addClass("history")
.text(rand)
);
const histories = $("#histories")[0];
histories.scroll(0, histories.scrollHeight);
numbers = numbers.filter(n => n !== rand);
});