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 183 views
1 answer 175 views
1 answer 151 views
1 answer 82 views
...