How to replace the first N characters in a string in TypeScript

1 Answer

0 votes
let str = 'typescript';
 
const N = 3; 
str = 'XYZ' + str.slice(N);
 
console.log(str);
 
 
   
   
   
   
/*
run:
 
"XYZescript" 
   
*/

 



answered Jun 12, 2022 by avibootz
...