--- title: "minMax" slug: "tools-minmax" updated: 2025-11-06T19:01:36Z published: 2025-11-06T19:01:36Z canonical: "docs.doc-know.com/tools-minmax" --- > ## Documentation Index > Fetch the complete documentation index at: https://docs.doc-know.com/llms.txt > Use this file to discover all available pages before exploring further. # minMax ### tools.minMax Checks the specified value and makes sure it is within the specified range. If less than the minimum, then the minimum is returned. If greater than the maximum, then the maximum is returned. Otherwise, the specified value is returned. ### Input Parameters | Name | Type | Required | Description | | --- | --- | --- | --- | | **value** | Number | Yes | Value to check if within range | | **min** | Number | Yes | Minimum allowed value in range | | **max** | Number | Yes | Maximum allowed value in range | ### Returns Type: **Number** Checks if the passed value is within range and returns the appropriate value. ### Examples ``` // checks to see if x is within the range of 10 to 20 // since true, 13 is returned var x = 13; x = tools.minMax(x, 10, 20); ``` ``` // since false, 10 is returned var x = 3; x = tools.minMax(x, 10, 20); ``` ``` // since false, 20 is returned var x = 147; x = tools.minMax(x, 10, 20); ``` ### Remarks Use this helper function when you want to restrict a value within a certain range. This allows you to perform this restriction within a single line of code.