How to remove all spaces from a string in TypeScript

2 Answers

0 votes
let s = "typescript  java c    c++ c#  php   python"
  
s = s.replace(/\s+/g,'').trim();
  
console.log(s); 
  
  
  
  
/*
run:
  
"typescriptjavacc++c#phppython" 
  
*/

 



answered Jan 29, 2022 by avibootz
0 votes
let s = "typescript  java c    c++ c#  php   python"
  
s = s.split(' ').join('');
  
console.log(s); 
  
  
  
  
/*
run:
  
"typescriptjavacc++c#phppython" 
  
*/

 



answered Jan 29, 2022 by avibootz
...