How to replace multiple characters in a string with other characters using JavaScript

1 Answer

0 votes
let str = 'java-script.type-script.c.php-';

str = str.replaceAll('.', ' ').replaceAll('a', 'X').replaceAll('-', '');
  
console.log(str); 




  
/*
run:
  
"jXvXscript typescript c php"
  
*/

 



answered Apr 28, 2022 by avibootz
edited Apr 28, 2022 by avibootz
...