(array, start, length)
| 20 | * @return {object} The random element that was removed, or `null` if there were no array elements that fell within the given range. |
| 21 | */ |
| 22 | var RemoveRandomElement = function (array, start, length) |
| 23 | { |
| 24 | if (start === undefined) { start = 0; } |
| 25 | if (length === undefined) { length = array.length; } |
| 26 | |
| 27 | var randomIndex = start + Math.floor(Math.random() * length); |
| 28 | |
| 29 | return SpliceOne(array, randomIndex); |
| 30 | }; |
| 31 | |
| 32 | module.exports = RemoveRandomElement; |
no test coverage detected
searching dependent graphs…