Parse number

Description

The parse-number function takes a string as a parameter and attempts to parse it as a numerical value. If the string can be parsed as a number, the function returns the numerical value. If the string cannot be parsed as a number, the function returns null.

Parameters

  • string: A string to be parsed as a number.

Examples

parse-number("42") => 42
parse-number("3.14") => 3.14
parse-number("-7") => -7
parse-number("1,000") => 1000
parse-number("not a number") => null