# REVERSE

**The function REVERSE takes either a List or a string and returns it in reverse order.**

This function takes a single piece of input: either a single [List](../../variable-data-types/the-list-data-type), or a single [string](../../variable-data-types/the-text-variable-data-type). It returns a value of the same data type it was given, with the items or characters placed in reverse order.

#### Declaration

```javascript
REVERSE(list_of_values) -> reversed
```

```javascript
REVERSE(string) -> reversed
```

#### Parameters

**list\_of\_values** (required, type: _List_)\
Any List.

**string** (required, type: string)\
Any string.

#### Return Values

**reversed** (type: _List_ or string)\
If a List was given as input, **reversed** is a List that contains the given List's items in reverse order. If a string was given as input, **reversed** is a string that contains the given string's characters in reversed order.

#### Examples

The following example takes the string "abcd" and reverses the characters in it:

```javascript
REVERSE("abcd") -> "dcba"
```

Special characters are maintained and reversed by the REVERSE function. In the following example, the capital "T", the space, and the period are all reversed just like any other character:

```javascript
REVERSE("This string.") -> ".gnirts sihT"
```

The above examples take strings as input and return them reversed. The following example takes a List of strings and returns a List of the given strings in the reverse order, through the characters in the stings themselves are not reversed. Note that the List given as input includes the string "This string!" from the above example, and yet the REVERSE function does not reverse the characters in it, because it is an item in the given a List:

```javascript
REVERSE(["This string!", "Another string.", "A third string"]) -> [
  "A third string",
  "Another string.",
  "This string!"
]
```
