Code coverage report for random/choice.js

Statements: 100% (6 / 6)      Branches: 100% (4 / 4)      Functions: 100% (3 / 3)      Lines: 100% (5 / 5)     

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