* Returns a new array containing numItems from arr * @param {any[]} arr * @param {number} numItems
(arr, numItems)
| 21 | * @param {number} numItems |
| 22 | */ |
| 23 | function sample(arr, numItems) { |
| 24 | const result = []; |
| 25 | const increment = arr.length / numItems; |
| 26 | const len = arr.length; |
| 27 | let i = 0; |
| 28 | |
| 29 | for (; i < len; i += increment) { |
| 30 | result.push(arr[Math.floor(i)]); |
| 31 | } |
| 32 | return result; |
| 33 | } |
| 34 | |
| 35 | /** |
| 36 | * @param {Scale} scale |
no outgoing calls
no test coverage detected