Travis build: 902
This commit is contained in:
@ -7,12 +7,12 @@ You can omit `start` to use a default value of `0`.
|
||||
You can omit `step` to use a default value of `1`.
|
||||
|
||||
```js
|
||||
const initializeArrayWithRange = (end, start = 0,step = 1) =>
|
||||
Array.from({length:Math.ceil((end + 1 - start)/step)}).map((v, i) => (i * step) + start);
|
||||
const initializeArrayWithRange = (end, start = 0, step = 1) =>
|
||||
Array.from({ length: Math.ceil((end + 1 - start) / step) }).map((v, i) => i * step + start);
|
||||
```
|
||||
|
||||
```js
|
||||
initializeArrayWithRange(5); // [0,1,2,3,4,5]
|
||||
initializeArrayWithRange(7, 3); // [3,4,5,6,7]
|
||||
initializeArrayWithRange(9,0,2); //[0,2,4,6,8]
|
||||
initializeArrayWithRange(9, 0, 2); //[0,2,4,6,8]
|
||||
```
|
||||
|
||||
Reference in New Issue
Block a user