How to pad a string on the right in TypeScript

2 Answers

0 votes
const str = "TS";
 
const padded = str.padEnd(6, '*');
 
console.log(padded); 
 
 
 
/*
run:
 
"TS****"
 
*/

 



answered Jul 3, 2025 by avibootz
0 votes
const str = "TS";
 
console.log(str.padEnd(5));
 
 
 
/*
run:
 
"TS   "
 
*/

 



answered Jul 3, 2025 by avibootz
...