-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.js
44 lines (32 loc) · 1.12 KB
/
main.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
39
40
41
42
43
44
$(document).ready(function() {
let $randomnbr = $('.nbr'),
$timer = 30,
$it,
$change,
$index,
$data = 0,
$letters = ['z', 'a', 'c', 'k', 'a', 'r', 'i', 'a' ];
$randomnbr.each(function() {
$change = Math.round(Math.random() * 100);
$(this).attr('data-change', $change)
});
function random() {
return Math.round(Math.random() *9);
}
function select() {
return Math.round(Math.random() * $randomnbr.length+1);
}
function value() {
$('.nbr:nth-child('+select()+')').html(''+random()+'');
$('.nbr:nth-child('+select()+')').attr('data-number', $data);
$data++;
$randomnbr.each(function() {
if(parseInt($(this).attr('data-number')) > parseInt($(this).attr('data-change'))) {
$index = $('.ltr').index(this);
$(this).html($letters[$index]);
$(this).removeClass('nbr');
}
});
}
it = setInterval(value, $timer );
})