You need to state which story format you are using, as answers can be different for each one.
Harlowe:
(set: $age to (prompt: "Your age is?"))
(if: $age is "" or isNaN($age))[
You did not enter a number, defaulting age to 18
(set: $age to 18)
]
(else:)[
Convert the text (String) numerical value into a number.
(set: $age to (num: $age))
]
Age is: $age
<<if isNaN($age)>>
You did not enter a number, defaulting age to 18
<<set $age to 18>>
<<else>>
Convert the text (String) numerical value into a number.
<<set $age to parseInt($age)>>
<<endif>>
Age is: $age
Comments
Harlowe:
SugarCube 1: Using <<textbox>> macro:
a. Main passage: b. Check Age passage: