How to convert comma separated string to numeric array in Node.js

1 Answer

0 votes
const str = '100,49,21,3,9,55,80';

const arr = str.split(',').map(element => {
  	return Number(element);
});

console.log(arr);
 
 
 
 
 
/*
run:
 
[100, 49, 21, 3, 9, 55, 80]
 
*/

 



answered Apr 11, 2022 by avibootz

Related questions

2 answers 192 views
1 answer 188 views
1 answer 163 views
1 answer 91 views
...