@stdlib/string-base-repeat
v0.2.2
Published
Repeat a string a specified number of times and return the concatenated result.
Downloads
1,646
Readme
repeat
Repeat a string a specified number of times and return the concatenated result.
Installation
npm install @stdlib/string-base-repeat
Usage
var repeat = require( '@stdlib/string-base-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-base-repeat' );
var i;
for ( i = 0; i < 100; i++ ) {
console.log( repeat( 'beep', discreteUniform( 0, 3 ) ) );
}
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.