How to replace all spaces with dashes in a string with JavaScript

1 Answer

0 votes
let str = 'javascript java c c++ php';
 
str = str.replaceAll(' ', '-');
 
console.log(str); 
 
    
    
    
    
/*
run:
    
"javascript-java-c-c++-php"
    
*/

 



answered Apr 26, 2022 by avibootz
...