range

range

Create an array of specific length with a step and an offset.

Import

import { range } from '@fullstacksjs/toolbox';

Signature

function range(length: number, offset: number = 0, step: number = 1): number[];

Examples

range(0);         // []
range(5);         // [0, 1, 2, 3, 4]
range(3, 5);      // [5, 6, 7]
range(3, -2, 10); // [-2, 8, 18]
range(3, 2, -4);  // [2, -2, -6]
range(3, -2, -1); // [-2, -3, -4]