const toNumbers = arr => arr.map(Number);
// Or
const toNumbers = arr => arr.map(x => +x);
// Example
toNumbers(['2', '3', '4']);
// [2, 3, 4]
const toNumbers = arr => arr.map(Number);
// Or
const toNumbers = arr => arr.map(x => +x);
// Example
toNumbers(['2', '3', '4']);
// [2, 3, 4]
For further actions, you may consider blocking this person and/or reporting abuse
If you're starting a new project, Neon has got your databases covered. No credit cards. No trials. No getting in your way.
Top comments (2)
You'll get
NaN
in following scenarios:Empty string ->
''
String with space
' '
function definition =>
() => {}
undefined value =>
undefined
null value =>
null
we can use ts or input validation when writing any function