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

1 Answer

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

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

*/

 



answered Apr 26, 2022 by avibootz

Related questions

1 answer 105 views
2 answers 139 views
1 answer 128 views
1 answer 123 views
...