# Run code

> Run a JavaScript snippet for anything the other nodes don't cover.

Source: https://docs.buildcord.dev/nodes/integrations/run-code/

`integration.code` runs JavaScript. Use it when no other node does what you need.

## Settings

| Setting | What it does |
| --- | --- |
| JavaScript | The body of a function. |

The run's values are on `ctx`: `ctx.user.name`, `ctx.option.a`, `ctx.var.score` and `ctx.secret.API_KEY`.

```js
return { total: Number(ctx.option.a) + Number(ctx.option.b) };
```

Code that several steps need belongs in a [script](https://docs.buildcord.dev/concepts/scripts), loaded by name:

```js
const scoring = require("scoring");
return { rank: scoring.rank(Number(ctx.var.points)) };
```

## Ways out

`out`. Turn on **If it fails** for a red way out.

## Produces

What the function returns. Later steps read it as `{code.total}`, or `{code.result}` if the return value isn't an object.

## Notes

- The snippet has one second to run and can't reach the network. Put [Send an API request](https://docs.buildcord.dev/nodes/integrations/api-request) before it, and read its answer as `ctx.http.body`.
- Braces in the code are code, not tokens.
- It needs a **gateway bot**, which the paid plan includes. See [Plans](https://docs.buildcord.dev/concepts/plans).

## Related

- [Scripts](https://docs.buildcord.dev/concepts/scripts)
- [Work out an equation](https://docs.buildcord.dev/nodes/variables-and-data/work-out-equation)
- [Manipulate text](https://docs.buildcord.dev/nodes/variables-and-data/manipulate-text)
