Array of Strings to Array of Numbers

Published by Werdna in

Create a function that takes as a parameter an array of "stringified" numbers and returns an array of numbers.

Example:

["1", "3", "3.6"] ➞ [1, 3, 3.6]

Examples

to_number_array(["9.4", "4.2"]) ➞ [9.4, 4.2]

to_number_array(["21", "23"]) ➞ [21, 23]

to_number_array(["9.5", "8.8"]) ➞ [9.5, 8.8]

Notes

Some inputs are floats.

Watch a quick demo on how Edabit works.