1 | var randInt = require('./randInt');
|
2 | var isArray = require('../lang/isArray');
|
3 |
|
4 | /**
|
5 | * Returns a random element from the supplied arguments
|
6 | * or from the array (if single argument is an array).
|
7 | */
|
8 | function choice(items) {
|
9 | var target = (arguments.length === 1 && isArray(items))? items : arguments;
|
10 | return target[ randInt(0, target.length - 1) ];
|
11 | }
|
12 |
|
13 | module.exports = choice;
|
14 |
|
15 |
|