# CONTAINS

**The CONTAINS function returns TRUE if a certain value is found in a given list, FALSE if not.**

This function takes two pieces of input: a [List](../../variable-data-types/the-list-data-type), and a value of any type that might be contained within that list. It then outputs a boolean indicating whether the list contains said value. (**TRUE** means it does, **FALSE** means it doesn't.)

#### Declaration

```javascript
CONTAINS(list_of_values, value_to_find) -> contained
```

#### Parameters

**list\_of\_values** (required, type: _list_) A list containing any number of items. These items can be of any type and do not need to be the same type as each other.

**value\_to\_find** (required, type: _any_) A value to be found among the items in the provided list.

#### Return Values

**contained** (type: _boolean_) A boolean value indicating whether **list\_of\_values** contains a certain item. **TRUE** means it does, **FALSE** means it doesn't.

#### Examples

The following example searches for the number 3 within the list \[1, 2, 3]. Because 3 is, in fact, contained within the list \[1, 2, 3], it outputs **TRUE**:

```javascript
CONTAINS([1, 2, 3], 3) -> TRUE
```

The above example hardcoded **list\_of\_values,** but this doesn't need to be the case. (For that matter, **value\_to\_find** doesn't need to be hardcoded either, though for the sake of clarity, it is in all of these examples.) Moving forward, assume all formulas have access to the following list:

```javascript
example_list = [1, "hello", "this is a string, John", [1, 2, 3], {"name":"John"}]
```

Note that **example\_list** consists of myriad [types of values.](../../variable-data-types/data-types-overview) The first value is a [number](../../variable-data-types/the-number-variable-data-type) (1), the second and third values are [strings](../../variable-data-types/the-text-variable-data-type) ("hello" and "this is a string, John"), the forth value is a [list](../../variable-data-types/the-list-data-type) ( \[1, 2, 3] ), and the fifth value is an [object](../../variable-data-types/the-list-data-type) ( {"name" :  "John"} ). This list was chosen not because it is particularly likely to be encountered it in the wild, but to emphasize that the values listed in **list\_of\_values** do not at all need to be same type as each other.   This next example searches for the string "hello" in the variable **example\_list**. Because **example\_list** contains the string "hello", it outputs **TRUE**:

```javascript
CONTAINS(example_list, "hello") -> TRUE
```

This third example searches for the string "John" in the variable **example\_list**. Because **example\_list** does not contain the string "John" – only the object {"name": "John"} and the string "this is a string, John" – it outputs **FALSE:**

```javascript
CONTAINS(example_list, "John") -> FALSE
```

Note that a list containing the string "this is a string, John" as well as the object {"name": "John"} does not count as a list containing the string "John". This highlights an important subtlety regarding what counts as a "value" within a "list." The CONTAINS function compares **value\_to\_find** with only the complete items within **list\_of\_values**, not any of their subcomponents.

"John" can be considered a subcomponent of the object {"name": "John"}, and while **example\_list** does not contain "John", it does contain {"name": "John"}. When the last example searches for the object {"name": "John"} within the variable **example\_list**, it outputs **TRUE:**

```javascript
CONTAINS(example_list, {"name": "John") -> TRUE
```
