How to remove all spaces from a string in Node.js

2 Answers

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

 



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

 



answered Jan 29, 2022 by avibootz

Related questions

1 answer 140 views
1 answer 178 views
1 answer 123 views
1 answer 140 views
1 answer 124 views
2 answers 141 views
...