How to replace white space in a string with + in JavaScript

1 Answer

0 votes
let s = 'javascript c php java';

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

console.log(s);



  
    
    
/*
run:
    
"javascript+c+php+java"
    
*/

 



answered May 25, 2021 by avibootz
...