# getValueOfStep()

## `Range.prototype.getValueOfStep()`

The `getValueOfStep()` method returns the range value of the given [`step`](#step-number).

{% hint style="warning" %}
If the given [`step`](#step-number) is not within range returns [`undefined`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/undefined).
{% endhint %}

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

```typescript
public getValueOfStep(step: number): number | undefined {
  return step > 0 && step <= this.steps ? this.range[step - 1] : undefined;
}
```

{% endcode %}

### Parameters

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

Step parameter of [`number`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number) type to retrieve the range value.

### Return type

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

### Returns

The **return value** is the range value of the given [`step`](#step-number) within a range otherwise [`undefined`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/undefined).

## Example usage

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

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

// Maximum steps is 19.
range.steps;

// Get value of step 3. Returns -21.
range.getValueOfStep(3);

// Get range to step 20. Returns undefined.
range.getValueOfStep(20);

// Get range to step 1. Returns -27.
range.getValueOfStep(1);
```


---

# 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/getvalueofstep.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.
