How to create a specific number of copies of a string in TypeScript

1 Answer

0 votes
function createCopies(str: string, num: number) {
    return str.repeat(num);
}
 
let s: string = "wpo";
 
s = createCopies(s, 3);
   
console.log(s);
   
   
   
/*
run:
   
"wpowpowpo"
   
*/

 



answered Dec 23, 2024 by avibootz
...