Code coverage report for array/pick.js

Statements: 100% (8 / 8)      Branches: 100% (2 / 2)      Functions: 100% (3 / 3)      Lines: 100% (6 / 6)     

All files » array/ » pick.js
1 2 3 4 5 6 7 8 9 10 11 12 13 14 151         1 2 1 1     1      
define(['../random/randInt'], function (randInt) {
 
    /**
     * Remove a random item from the Array and return it
     */
    function pick(arr){
        if (! arr.length) return;
        var idx = randInt(0, arr.length - 1);
        return arr.splice(idx, 1)[0];
    }
 
    return pick;
 
});