How to add N spaces to end of string in Node.js

1 Answer

0 votes
let str = 'nodejs java c c++ php';
 
const N = 5;

str = str + ' '.repeat(N);
 
console.log(str + '.'); 
 
    
    
    
    
/*
run:
    
nodejs java c c++ php     .

*/

 



answered Apr 26, 2022 by avibootz

Related questions

1 answer 131 views
2 answers 153 views
3 answers 239 views
1 answer 141 views
1 answer 212 views
1 answer 142 views
...