How to replace the last character in a string with multiple characters in Node.js

1 Answer

0 votes
let str = 'javascript typescript node.js python';
 
str = str.slice(0, -1) + 'MNM';
 
console.log(str); 

   
   
   
   
/*
run:
   
javascript typescript node.js pythoMNM
   
*/

 



answered Jul 3, 2022 by avibootz
...