# getRange()

## `Range.prototype.getRange()`

The `getRange()` method returns a range of numbers by the specified [`step`](https://range.angular-package.dev/draft/range/accessors/get-step) from [minimum](https://range.angular-package.dev/draft/range/properties/min) to the given [`value`](#value-number-this.max) of the specified [`Range`](https://range.angular-package.dev/draft/range) object.

{% code title="range.class.ts" %}

```typescript
public getRange(value: number = this.max): Readonly<Array<number>> {
  const range = [];
  let current: number = this.min;
  while (current <= value) {
    current <= this.max && range.push(current), (current += this.#step);
  }
  return range;
}
```

{% endcode %}

### Parameters

#### `value:`[<mark style="color:green;">`number`</mark>](https://www.typescriptlang.org/docs/handbook/basic-types.html#number)`= this.max`

Optional maximum range value of [`number`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number) type of returned [`array`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array) by default it's the [maximum](https://range.angular-package.dev/draft/range/properties/max) range.

### Return type

#### [<mark style="color:green;">`Readonly`</mark>](https://www.typescriptlang.org/docs/handbook/utility-types.html#readonlytype)`<`[<mark style="color:green;">`Array`</mark>](https://www.typescriptlang.org/docs/handbook/2/everyday-types.html#arrays)`<`[<mark style="color:green;">`number`</mark>](https://www.typescriptlang.org/docs/handbook/basic-types.html#number)`>>`

### Returns

The **return value** is a range of numbers of a read-only [`Array`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array) from [minimum](https://range.angular-package.dev/draft/range/properties/min) to the given [`value`](#value-number-this.max).

## Example usage

```typescript
// Example usage.
import { Method } from '@angular-package/range';

// Create new instance.
// Returns Range {min: 3, max: 27, value: 10} of Range<3, 27, 3>.
const range = new Range(3, 27, 10, 3);

// Returns (9) [3, 6, 9, 12, 15, 18, 21, 24, 27] of readonly number[]
range.getRange();

// Returns (3) [3, 6, 9] of readonly number[]
range.getRange(10);
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://range.angular-package.dev/draft/range/methods/getrange.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
