syedsimanta03 Posted on May 25, 2021 Convert an array of strings to numbers #javascript #react #reactnative #vue const toNumbers = arr => arr.map(Number); // Or const toNumbers = arr => arr.map(x => +x); // Example toNumbers(['2', '3', '4']); // [2, 3, 4] Top comments (2) Subscribe Submit Preview Dismiss Collapse Expand Itachi Uchiha Itachi Uchiha Itachi Uchiha Follow I'm a front-end developer. I'm living in Turkey. I started my professional career in 2016. I also interest in Backend, SQL technologies. Email goren.ali@yandex.com Location Turkey Education Web Dev Work Jr. Fullstack Developer at FOSS Dev Joined Nov 21, 2017 • May 26 '21 Dropdown menu Copy link Hide You'll get NaN in following scenarios: Empty string -> '' String with space ' ' function definition => () => {} undefined value => undefined null value => null Collapse Expand syedsimanta03 syedsimanta03 syedsimanta03 Follow UI designer | Front end developer | Graphic designer #OpenToWork » Tools: GIT, VS Code, Adobe XD, Figma, Photoshop, Illustrator Email syed.simanta06@gmail.com Work Frontend | UI designer Joined May 18, 2021 • May 26 '21 Dropdown menu Copy link Hide we can use ts or input validation when writing any function Code of Conduct • Report 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