Skip to main content

confirm

function confirm
Jump to headingconfirm(message?: string): boolean

Shows the given message and waits for the answer. Returns the user's answer as boolean.

Only y and Y are considered as true.

If the stdin is not interactive, it returns false.

Jump to heading

Example 1

const shouldProceed = confirm("Do you want to proceed?");

// If the user presses 'y' or 'Y', the result will be true
// If the user presses 'n' or 'N', the result will be false
console.log("Should proceed?", shouldProceed);

Parameters Jump to heading

optional
Jump to headingmessage: string

Return Type Jump to heading

boolean
Back to top