How to create a specific number of copies of a string in Node.js

1 Answer

0 votes
function createCopies(str, num) {
    return str.repeat(num);
}
 
let s = "xyz";
 
s = createCopies(s, 4);
   
console.log(s);
   
   
   
/*
run:
   
xyzxyzxyzxyz
   
*/



 

 



answered Dec 23, 2024 by avibootz
...