# Script

This is a task that executes a script written in JavaScript syntax and returns the result.

## Parameters

- script
  - Write in JavaScript syntax.
  - The global object is a simple object that contains data and variables from the corresponding [Scenario Context](../concept/scenario-context.md). In other words, within the script, you can use the data, variables, domain, user, and lng variables from the scenario's [Script Built-in Variables](../concept/script-internal-variables.md) without any special modifiers or through the `this` accessor.
  - The task's execution result is returned through the `return` syntax.
  - Since the global object within the script is limited to data and variables, as well as other [Script Built-in Variables](../concept/script-internal-variables.md), consider it a sandbox environment where most system-related functionalities are unavailable. It's recommended to implement simple operations.
    - [Node Sandbox](https://medium.com/@devnullnor/a-secure-node-sandbox-f23b9fc9f2b0)
    - [vm2](https://github.com/patriksimek/vm2/blob/master/README.md)

## Sample Scripts

```
return data['step1'].map(record => {
  return {
    ...record,
    id: 'PREFIX-' + record.id
  }
})
```

```
return Math.floor(Number(this.data['step2']))
```

```
return this.data['step3'].map(record => {
  return {
    ...record,
    id: (this.variables.prefix || 'DEFAULT-') + record.id
  }
})
```
