Methods
generateRange(from, to, stepopt, nullable) → {Array}
To remove these by reference from target, instead of iterating them, set "to" to true.
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
from |
Number | String | the start of the range, may also be negative, if larger than "to", the range is created in reverse, as a string, this can be a single character |
||
to |
Number | String | the end of the range, may also be negative, if smaller than "from", the range is created in reverse, as a string, this can be a single character |
||
step |
Number |
<optional> <nullable> |
null | the (positive) step length in the range to use between individual range values, if the step length does not hit "to" exactly, the range will end at the last possible value before "to" |
Throws:
error if "from" or "to" are empty strings
Returns:
new array with generated range
- Type
- Array
Example
generateRange(0, 10, 2)
=> [0, 2, 4, 6, 8, 10]
generateRange(5, -5, 3.5)
=> [5, 1.5, -2]
generateRange('a', 'g, 3)
=> ['a', 'd', 'g']