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 134 views
1 answer 175 views
1 answer 119 views
1 answer 131 views
1 answer 117 views
2 answers 136 views
...