'how to convert a string array to number array?
I am trying to convert a string array to a number array A quick google search have lead me to this solution.
let numbersAsStringArray = originalQueryParams[property] ?? []
let numbers = numbersAsStringArray.map((i) => Number(i));
where I keep getting this i
Property 'map' does not exist on type 'string | string[]'.
numbersAsStringArray is just an simple array with a number in as a string.
Solution 1:[1]
You can try let numbers = Array.from(numbersAsStringArray,Number)
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Jinadi Yasiruka |
