How to insert string at specific index of another string in Node.js

1 Answer

0 votes
let str = "NodeJS Python C";
const string = 'C++';

const index = 7;

str = str.slice(0, index) + string + str.slice(index);

console.log(str);
 
 
 
 
/*
run:
 
NodeJS C++Python C
 
*/

 



answered May 1, 2022 by avibootz

Related questions

...