Fully renamed and updated everything, tagged, built
This commit is contained in:
11
snippets/initializeArrayWithValues.md
Normal file
11
snippets/initializeArrayWithValues.md
Normal file
@ -0,0 +1,11 @@
|
||||
### initializeArrayWithValues
|
||||
|
||||
Initializes and fills an array with the specified values.
|
||||
|
||||
Use `Array(n)` to create an array of the desired length, `fill(v)` to fill it with the desired values.
|
||||
You can omit `value` to use a default value of `0`.
|
||||
|
||||
```js
|
||||
const initializeArrayWithValues = (n, value = 0) => Array(n).fill(value);
|
||||
// initializeArray(5, 2) -> [2,2,2,2,2]
|
||||
```
|
||||
Reference in New Issue
Block a user