How to pad a string on the right in Node.js

2 Answers

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

 



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

 



answered Jul 3, 2025 by avibootz

Related questions

...