# Variables

> Discover how to utilize and customize script variables for dynamic scripting capabilities with env.vars.

The `env.vars` object contains a set of variable values. You can use these variables to parameterize your script.

```js
// grab locale from variable or default to en-US
const locale = env.vars.locale || "en-US"
// conditionally modify prompt
if (env.vars.explain)
    $`Explain your reasoning`
```

### Script parameters

[Section titled “Script parameters”](#script-parameters)

It is possible to declare parameters in the `script` function call. The `env.vars` object will contain the values of these parameters.

```js
script({
    parameters: {
        string: "the default value", // a string parameter with a default value
        number: 42, // a number parameter with a default value
        boolean: true, // a boolean parameter with a default value
        stringWithDescription: {
            // a string parameter with a description
            type: "string",
            default: "the default value",
            description: "A description of the parameter",
        },
    },
})
```

When invoking this script in VS Code, the user will be prompted to provide values for these parameters.

### Variables from the CLI

[Section titled “Variables from the CLI”](#variables-from-the-cli)

Use the `vars` field in the CLI to override variables. vars takes a sequence of `key=value` pairs.

```sh
npx genaiscript run ... --vars myvar=myvalue myvar2=myvalue2 ...
```

### Variables in tests

[Section titled “Variables in tests”](#variables-in-tests)

You can specify variables in the `tests` object of the `script` function. These variables will be available in the test scope.

```js
script({
    ...,
    tests: {
        ...,
        vars: {
            number: 42
        }
    }
})
```