Repeat a string a specified number of times and return the concatenated result.
var repeat = require( '@stdlib/utils/repeat-string' );
Repeats a string n
times and returns the concatenated result.
var str = repeat( 'a', 5 );
// returns 'aaaaa'
str = repeat( '', 100 );
// returns ''
str = repeat( 'beep', 0 );
// returns ''
var round = require( '@stdlib/math/base/special/round' );
var repeat = require( '@stdlib/utils/repeat-string' );
var str = 'beep';
var n;
var i;
for ( i = 0; i < 100; i++ ) {
n = round( Math.random()*3 );
console.log( repeat( str, n ) );
}
Usage: repstr [options] str --n repeats
Options:
-h, --help Print this message.
-V, --version Print the package version.
--n repeats Number of repetitions.
$ repstr beep -n 5
# => beepbeepbeepbeepbeep