Tag, lint, build

This commit is contained in:
Angelos Chalaris
2017-12-15 12:53:09 +02:00
parent 14543a15b6
commit 453026fe3b
8 changed files with 94 additions and 32 deletions

View File

@ -1,9 +1,9 @@
### Array sample
Use `Math.random()` to generate a random number, multiply it with `Array.length` and round it of to the nearest whole number using `Math.floor()`. Works with strings too.
Use `Math.random()` to generate a random number, multiply it with `length` and round it of to the nearest whole number using `Math.floor()`.
This method also works with strings.
```js
const sample = arr => arr[Math.floor(Math.random() * arr.length)];
// sample([3, 7, 9, 11]) -> 9
```
// sample([3, 7, 9, 11]) -> 9
```