@stdlib/string-repeat
v0.2.2
Published
Repeat a string a specified number of times and return the concatenated result.
Downloads
1,554
Readme
repeat
Repeat a string a specified number of times and return the concatenated result.
Installation
npm install @stdlib/string-repeat
Usage
var repeat = require( '@stdlib/string-repeat' );
repeat( str, n )
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 ''
Examples
var discreteUniform = require( '@stdlib/random-base-discrete-uniform' );
var repeat = require( '@stdlib/string-repeat' );
var i;
for ( i = 0; i < 100; i++ ) {
console.log( repeat( 'beep', discreteUniform( 0, 3 ) ) );
}
See Also
@stdlib/string-repeat-cli
: CLI package for use as a command-line utility.@stdlib/string-pad
: pad a string.
Notice
This package is part of stdlib, a standard library for JavaScript and Node.js, with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more.
For more information on the project, filing bug reports and feature requests, and guidance on how to develop stdlib, see the main project repository.
Community
License
See LICENSE.
Copyright
Copyright © 2016-2024. The Stdlib Authors.