-
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.js
More file actions
35 lines (34 loc) · 759 Bytes
/
index.js
File metadata and controls
35 lines (34 loc) · 759 Bytes
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
export default function age(options) {
options = options || {};
let min = 0;
let max = 100;
switch (options.type) {
case 'child':
min = 0;
max = 12;
break;
case 'teen':
min = 13;
max = 19;
break;
case 'adult':
min = 18;
max = 65;
break;
case 'senior':
min = 65;
max = 100;
break;
case 'all':
min = 0;
max = 100;
break;
default:
min = 0;
max = 100;
break;
}
min = Math.ceil(min);
max = Math.floor(max);
return Math.floor(Math.random() * (max - min + 1)) + min;
}