How to remove all whitespace from string in Node.js

1 Answer

0 votes
let str = '   node.js\n      c++ \n      ';

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

console.log(str);

  
  
  
  
/*
run:
  
node.jsc++
  
*/

 



answered Jun 10, 2022 by avibootz
...