# map

## Description

Loop through all the elements in a list to apply a specific operation to each element.

Example: loop through a list of numbers to square (operation to be applied) every number.

## Input / Parameter

| Name   | Description                                     | Input Type | Default | Options | Required |
| ------ | ----------------------------------------------- | ---------- | ------- | ------- | -------- |
| values | The list of elements to loop through.           | Array/List | -       | -       | Yes      |
| extra  | Extra parameters stored and passed to callback. | Any        | -       | -       | No       |

## Output

N/A

## Callback

### yesCallback

This will be triggered for every loop that happens within the 'values'.

| Description                                   | Output Type |
| --------------------------------------------- | ----------- |
| The current active value within the 'values'. | Any         |

## Video

Coming Soon.

## Example

The user wants to loop through all the values in an array.

### Step

1. Set a variable "Vmap" using the `setVar` function. Call the function `toArray` in the `value` parameter and set the values for the list.\
   var: Vmap

   ![](https://399701567-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FwmJ1RKjM2uNFaL6fO3Xu%2Fuploads%2Fgit-blob-6dc4426affdab820ec0f206e277f9371d863c7a1%2Fmap-step-1.png?alt=media)

   ![](https://399701567-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FwmJ1RKjM2uNFaL6fO3Xu%2Fuploads%2Fgit-blob-dabe8eff6341f17b2ead9ed1cc874086f3c41b6e%2Fmap-step-2.png?alt=media)

   ![](https://399701567-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FwmJ1RKjM2uNFaL6fO3Xu%2Fuploads%2Fgit-blob-be058245cad1e251c5811962961ff93a18b5613c%2Fmap-step-3.png?alt=media)
2. Call the function `map`. Call the function `getVar` in the `values` parameter and enter the variable to get.\
   var : getVar->Vmap<br>

   ![](https://399701567-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FwmJ1RKjM2uNFaL6fO3Xu%2Fuploads%2Fgit-blob-f377213cf8d2168e97f756563290fa92a9a4dac0%2Fmap-step-4.png?alt=media)

   ![](https://399701567-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FwmJ1RKjM2uNFaL6fO3Xu%2Fuploads%2Fgit-blob-bb986c0b337df3ad138011a9b47e2712e83fa06b%2Fmap-step-5.png?alt=media)

   ![](https://399701567-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FwmJ1RKjM2uNFaL6fO3Xu%2Fuploads%2Fgit-blob-455e374e0352f74b845a4e80f5b8ea284fb8c62d%2Fmap-step-6.png?alt=media)
3. Add a `console` function to the callback of the `map` function to display the result in the console.

   ![](https://399701567-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FwmJ1RKjM2uNFaL6fO3Xu%2Fuploads%2Fgit-blob-5ff85f01d65e2654eaac1b40ffadc2fe63022500%2Fmap-step-7.png?alt=media)

   ![](https://399701567-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FwmJ1RKjM2uNFaL6fO3Xu%2Fuploads%2Fgit-blob-53ebe82e36e43664ee0ce13fd94015ffce8f42cb%2Fmap-step-8.png?alt=media)

### Result

![](https://399701567-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FwmJ1RKjM2uNFaL6fO3Xu%2Fuploads%2Fgit-blob-ffab9b822a89a2e93ce16dfa143cf20a2e0a1bcf%2Fmap-result-1.png?alt=media)

## Links
