Updated snippets

Mainly for better readability
This commit is contained in:
Angelos Chalaris
2017-12-12 18:21:53 +02:00
parent 7758e59f0e
commit e2d2b6aa41
5 changed files with 12 additions and 14 deletions

View File

@ -1,9 +1,9 @@
### Initialize array with values
Use `Array(n)` to create an array of the desired length, `fill(v)` to fill it with the desired values.
You can omit `v` to use a default value of `0`.
You can omit `value` to use a default value of `0`.
```js
const initializeArray = (n, v = 0) => Array(n).fill(v);
const initializeArray = (n, value = 0) => Array(n).fill(value);
// initializeArray(5, 2) -> [2,2,2,2,2]
```