8000 GitHub - stdlib-js/string-base-repeat at b5568c82a821c4b4d94201a8a498052e6caecce6
[go: up one dir, main page]

Skip to content

Repeat a string a specified number of times and return the concatenated result.

License

Notifications You must be signed in to change notification settings

stdlib-js/string-base-repeat

Repository files navigation

repeat

NPM version Build Status Coverage Status

Repeat a string a specified number of times and return the concatenated result.

Installation

npm install @stdlib/string-base-repeat

Alternatively,

The branches.md file summarizes the available branches and displays a diagram illustrating their relationships.

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

Chat


License

See LICENSE.

Copyright

Copyright © 2016-2023. The Stdlib Authors.

0