getRangeOfStep()

Returns a range of numbers by the specified step from the minimum to the given `step` of a specified `Range` object

Range.prototype.getRangeOfStep()

The getRangeOfStep() method returns a range of numbers by the specified step from the minimum to the given step of a specified Range object.

range.class.ts
public getRangeOfStep(step: number): Readonly<Array<number>> {
  const range = [];
  if (step > 0 && step <= this.steps) {
    for (let value = 0; value < step; value++) {
      range.push(this.min + value * this.#step);
    }
  }
  return range;
}

Parameters

step:number

Step of number type is the maximum range of the returned array.

Return type

Returns

The return value is a range of numbers of a read-only Array from minimum to step of the given step if the given step is within a range, otherwise an empty Array.

Example usage

Last updated

Was this helpful?