Skip to content

Function: askNumber() ​

askNumber(message, allowDecimals?): number | null

Defined in: interaction.ts:164

Prompts the user to enter a numeric value. Returns the parsed number, or null if the input is not a valid number or if the user cancelled. Commas are accepted as decimal separators (eg. 3,14 is treated as 3.14).

Parameters ​

message ​

string

The message to display in the prompt dialog.

allowDecimals? ​

boolean = false

Whether to allow decimal numbers. Defaults to false.

Returns ​

number | null

Returns the parsed number, or null if the input is invalid or cancelled.

Example ​

ts
const age = facile.askNumber('How old are you?');
const price = facile.askNumber('Enter a price:', true);