[**@bondsports/general**](../README.md) • **Docs**

***

[@bondsports/general](../globals.md) / insertIf

# Function: insertIf()

> **insertIf**\<`T`\>(`condition`, ...`elements`): `T`[]

Inserts elements into an array if a condition is true.

## Type Parameters

• **T** = `any`

The type of elements in the array.

## Parameters

• **condition**: `boolean`

The condition to check.

• ...**elements**: `T`[]

The elements to insert into the array.

## Returns

`T`[]

- The resulting array.

## Defined in

[utils/array.util.ts:59](https://github.com/Bond-Sports/bondUtils/blob/545f16ceb055481acfd7641d7809c0f252d3a5e6/packages/general/src/utils/array.util.ts#L59)
