How to add N spaces to end of string in JavaScript

1 Answer

0 votes
let str = 'javascript java c c++ php';

const N = 5;

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

 



answered Apr 26, 2022 by avibootz

Related questions

1 answer 114 views
1 answer 107 views
1 answer 134 views
1 answer 227 views
2 answers 134 views
1 answer 131 views
...