How to convert comma separated string to numeric array in TypeScript

1 Answer

0 votes
const str = '7, 8, 0, 112, 69, 3, 97';
 
const arr = str.split(',').map(element => {
    return Number(element);
});
 
console.log(arr);
  
  
  
  
  
/*
run:
  
[7, 8, 0, 112, 69, 3, 97] 
  
*/

 



answered Apr 11, 2022 by avibootz

Related questions

...