# setValue()

## `Range.prototype.setValue()`

The method `setValue()` sets the range [value](https://range.angular-package.dev/draft/range/accessors/value) between the [minimum](https://range.angular-package.dev/draft/range/properties/min) and [maximum](https://range.angular-package.dev/draft/range/properties/max) of a specified [`Range`](https://range.angular-package.dev/draft/range) object.

{% hint style="warning" %}
If the given [`value`](#value-number) is not within range, it's not set.
{% endhint %}

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

```typescript
public setValue(value: number): this {
  this.value = value;
  return this;
}
```

{% endcode %}

### Parameters

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

The value of [`number`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number) type to set.

### Return type

#### [<mark style="color:green;">`this`</mark>](https://range.angular-package.dev/draft/range)

### Returns

The **return value** is the [`Range`](https://range.angular-package.dev/draft/range) instance.

## Example usage

```typescript
// Example usage.
import { Range } 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 10 of type number | undefined.
range.setValue(300).value;

// Returns 27 of type number | undefined.
range.setValue(27).value;
```


---

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