Update snippet descriptions
This commit is contained in:
@ -5,7 +5,8 @@ tags: array,random,beginner
|
||||
|
||||
Returns a random element from an array.
|
||||
|
||||
- Use `Math.random()` to generate a random number, multiply it by `length` and round it off to the nearest whole number using `Math.floor()`.
|
||||
- Use `Math.random()` to generate a random number.
|
||||
- Multiply it by `Array.prototype.length` and round it off to the nearest whole number using `Math.floor()`.
|
||||
- This method also works with strings.
|
||||
|
||||
```js
|
||||
|
||||
Reference in New Issue
Block a user