Converts any string to a number
It detects the type of any input string and converts it to a number with the most likely type
The input string to convert (e.g., 'IV', 'twenty-one', '一百二十三', '萬億')
The converted number
Error if the type is not supported or conversion fails
This function is a shortcut for convertFrom(str, getTypes(str)[0])
convertFrom(str, getTypes(str)[0])
anyToNumber('123') // returns 123anyToNumber('IV') // returns 4anyToNumber('twenty-one') Copy
anyToNumber('123') // returns 123anyToNumber('IV') // returns 4anyToNumber('twenty-one')
Converts any string to a number
It detects the type of any input string and converts it to a number with the most likely type