# forEachStep()

## `Range.prototype.forEachStep()`

The `forEachStep()` method performs the specified action for each step in the [maximum](/range/properties/max.md) range of an [`Array`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array).

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

```typescript
public forEachStep(
  forEachStep: (value: number, step: number, range: readonly number[]) => void
): this {
  this.range.forEach(forEachStep);
  return this;
}
```

{% endcode %}

### Parameters

#### `forEachStep: (value:`<mark style="color:green;">`number`</mark>`, step:`<mark style="color:green;">`number`</mark>`, range: readonly`<mark style="color:green;">`number`</mark>`[]) => void`&#x20;

A function that accepts up to three arguments. It's called one time for each step in the range.

### Return type

#### [<mark style="color:green;">`this`</mark>](/range/overview.md)

### Returns

The **return value** is the [`Range`](/range/overview.md) instance.

## Example usage

### Maximum range

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

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

range.forEachStep((value, step, r) => {
  // 4 - 5.5 - 7 - 8.5 - 10
  value;
  // 0 - 1 - 2 - 3 - 4
  step;
  // (5) [4, 5.5, 7, 8.5, 10]
  r;
});
```


---

# 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/range/methods/foreachstep.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.
