# increment

Learn how to increment a value by a given amount.

This method chains an `increment` operation to the patch, which increments a numeric value by a given amount.

Non-existent paths and null values are treated as zero.

> **Atomicity**
>
> If the value at the specified path is not a number, the operation fails and the entire patch is discarded.

## Signature

This method has the following signature:

```ts
patch.increment(path: string, value: number = 1): Patch
```

The return is the `Patch` instance itself to allow operation chaining.

## Example

Here is a basic example of how to use this method:

```ts
patch.increment('score', 10);
```

The following table shows how the operation behaves in different scenarios:

| Current value | Amount | Result |
| ------------- | ------ | ------ |
| `null`        | `10`   | `10`   |
| `0`           | `10`   | `10`   |
| `-1`          | `10`   | `9`    |

## Parameters

The following list describes the supported parameters:

- `path`: `string`

  The path to the value to increment in dot notation, like `points`.

- `value`: `number` (optional) (default: 1)

  The amount to increment the value by, like `2`.
