# `randomInt`

## Description

Returns a pseudorandom integer between `0` (inclusive) and an upper bound (exclusive).

Note

`randomInt` is not cryptographically secure.

## Syntax

Like many functions in DataPrime, `randomInt` supports [two notations](https://coralogix.com/docs/dataprime/language-reference/functions-reference/index.md), **function** and **method** notation. These interchangeable forms allow flexibility in how you structure expressions.

```dataprime
randomInt(upperBound: number): number
```

```dataprime
(upperBound: number).randomInt(): number
```

## Arguments

| Name       | Type   | Required | Description                                     |
| ---------- | ------ | -------- | ----------------------------------------------- |
| upperBound | number | **true** | The exclusive upper limit for the random number |

## Example

**Use case: Generate a random integer within a range**

Create a pseudorandom integer between `0` and `99` and attach it to each document.

### Example data

```json
{
    "event": "login_attempt"
}
```

### Example query

```dataprime
create random_num from randomInt(100)
```

```dataprime
create random_num from 100.randomInt()
```

### Example output

```json
{
    "event": "login_attempt",
    "random_num": 57
}
```
