The confirm() function in JavaScript displays a dialog box with a message and two buttons, OK and Cancel. The function returns true if the user clicks OK and false if the user clicks Cancel.
Here is an example of how to use the confirm() function:
In this example, a dialog box with the message "Are you sure you want to proceed?" is displayed. If the user clicks OK, the code in the first if block runs. If the user clicks Cancel, the code in the second if block runs.