How to remove all whitespace from string in TypeScript

1 Answer

0 votes
let str = '   typescript\n      c++ \n      ';

str = str.replace(/\s/g, '');

console.log(str);

  
  
  
  
/*
run:
  
"typescriptc++" 
  
*/

 



answered Jun 10, 2022 by avibootz
...