function confirm
#confirm(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.
Examples #
#
Example 1
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 #
optional
#message: string
Return Type #
boolean