How to replace the first N characters in a string in Node.js

1 Answer

0 votes
let str = 'node.js';
 
const N = 3; 
str = 'XYZ' + str.slice(N);
 
console.log(str);
 
 
   
   
   
   
/*
run:
 
XYZe.js
   
*/

 



answered Jun 12, 2022 by avibootz

Related questions

...