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
Top comments (2)
You'll get
NaNin following scenarios:Empty string ->
''String with space
' 'function definition =>
() => {}undefined value =>
undefinednull value =>
nullwe can use ts or input validation when writing any function