> For clean Markdown content of this page, append .md to this URL. For the complete documentation index, see https://learning.postman.com/llms.txt.

# Use TypeScript in an Evaluate block

You can use TypeScript to process and manipulate data in [**Evaluate**](/flows/reference/blocks/evaluate/), [**Condition**](/flows/reference/blocks/condition/), and [**If**](/flows/reference/blocks/if/) blocks in your flows. For example, you might use TypeScript to format a timestamp, check a response for errors, or select an item from a list.

## Recipe

The following recipe describes how to use TypeScript with an **Evaluate** block to select a random item from a list:

1. Create a flow and add an **HTTP Request** block. For this example, send a GET request to `https://openlibrary.org/subjects/love.json?limit=5`.

   This gets a list of five book titles.

2. Connect an **Evaluate** block to the **HTTP Request** block's **Success** port.

3. In the **Evaluate** block, name the variable `items` and set it to `body.works`.

4. Enter the following TypeScript in the **Evaluate** block to select a random title from the response:

   ```js
   items[Math.floor(Math.random() * items.length)].title
   ```

5. Run the flow and click the **Evaluate** block's **Result** output port to see the selected title.

## Try it out

To see this recipe's completed flow, check out [Cookbook: Use TypeScript to select a random item from a list](https://www.postman.com/postman/flows-snippets/flow/68befc03566b1a00131c230f/). You can also [clone this flow](/flows/build-flows/create/clone-flows/) to your workspace to experiment with it.