Travis build: 1231

This commit is contained in:
30secondsofcode
2018-01-15 12:03:06 +00:00
parent f2fcf1abe0
commit cc43b1117c
4 changed files with 30 additions and 3 deletions

View File

@ -229,6 +229,7 @@ average(1, 2, 3);
* [`percentile`](#percentile)
* [`powerset`](#powerset)
* [`primes`](#primes)
* [`randomIntArrayInRange`](#randomintarrayinrange)
* [`randomIntegerInRange`](#randomintegerinrange)
* [`randomNumberInRange`](#randomnumberinrange)
* [`round`](#round)
@ -3504,6 +3505,29 @@ primes(10); // [2,3,5,7]
<br>[⬆ Back to top](#table-of-contents)
### randomIntArrayInRange
Returns an array of n random integers in the specified range.
Use `Array.from()` to create an empty array of the specific length, `Math.random()` to generate a random number and map it to the desired range, using `Math.floor()` to make it an integer.
```js
const randomIntArrayInRange = (min, max, n = 1) =>
Array.from({ length: n }, () => Math.floor(Math.random() * (max - min + 1)) + min);
```
<details>
<summary>Examples</summary>
```js
randomIntArrayInRange(12, 35, 10); // [ 34, 14, 27, 17, 30, 27, 20, 26, 21, 14 ]
```
</details>
<br>[⬆ Back to top](#table-of-contents)
### randomIntegerInRange
Returns a random integer in the specified range.

File diff suppressed because one or more lines are too long

View File

@ -140,8 +140,8 @@ pull:array
pullAtIndex:array
pullAtValue:array
randomHexColorCode:utility,random
randomIntegerInRange:math,utility,random
randomIntArrayInRange:math,utility,random
randomIntegerInRange:math,utility,random
randomNumberInRange:math,utility,random
readFileLines:node,array,string
redirect:browser,url