# Javascript: CommentCollection.addReply Method

> Creates a reply to an existing comment using the specified comment string.

- **Product:** DS Server
- **Section:** Reference
- **Kind:** Method
- **Introduced:** 30.0
- **Path:** DS Server > Reference > JavaScript API > Javascript: CommentCollection.addReply Method
- **472 words**
- **Web URL:** https://docs.textcontrol.com/ds-server/reference/javascript/commentcollection/addreply-method/
- **LLMs URL:** https://docs.textcontrol.com/ds-server/reference/javascript/commentcollection/addreply-method/llms.txt
- **LLMs-Full URL:** https://docs.textcontrol.com/ds-server/reference/javascript/commentcollection/addreply-method/llms-full.txt

---

### Description

Creates a reply to an existing comment using the specified comment string.

### Syntax

```javascript
<void> CommentCollection.addReply(<string> comment, <CommentedText> repliedComment, [<AddCommentCallback> callback], [<ErrorCallback> errorCallback])
```

### Parameters

| Parameter | Description |
|---|---|
| comment | The comment string. |
| repliedComment | The comment to which to reply. |
| callback | Optional. Receives the result of the add operation. |
| errorCallback | Optional. Is called when the operation failed with an error. |

### Examples

The following example resolves the comment at the input position and adds a review reply to it.

```javascript
function onTxError(error) {
    console.error("TX Text Control error:", error.msg);
    error.handled = true;
}

TXTextControl.textParts.getMainText(function(mainText) {
    mainText.comments.getItem(function(currentComment) {
        if (!currentComment) {
            console.warn("Place the input position in a comment.");
            return;
        }

        mainText.comments.addReply(
            "I reviewed this section and approved the change.",
            currentComment,
            function(response) {
                console.log("Reply added:", response);
            },
            onTxError
        );
    }, onTxError);
}, onTxError);
```

---

## Nearby

- **Previous:** [Javascript: CommentCollection.addAtPosition Method](https://docs.textcontrol.com/ds-server/reference/javascript/commentcollection/addatposition-method/llms-full.txt)
- **Next:** [Javascript: CommentCollection.getItem Method](https://docs.textcontrol.com/ds-server/reference/javascript/commentcollection/getitem-method/llms-full.txt)
