How to replace multiple character at a specific index in a string with Node.js

1 Answer

0 votes
let str = "node.js php python c++";
  
const index = 2;
const replacement = 'RGBA';

str = str.substring(0, index) + replacement + str.substring(index + replacement.length);
  
console.log(str); 
 
 
 
  
  
/*
run:
  
noRGBAs php python c++
 
*/

 



answered Jul 4, 2022 by avibootz
...