stickycase

Convert a string to sticky case.

Usage

var stickycase = require( '@stdlib/string/base/stickycase' );

stickycase( str[, p] )

Converts a string to sticky case, where each character in the input string is randomly converted to either uppercase or lowercase.

var str = 'hello world';
var out = stickycase( 'hello world' );
// returns <string>

By default, the probability for any character to be capitalized is 0.5. To set a different probability, provide a p argument.

var str = 'welcome!';
var out = stickycase( 'welcome!', 0.2 );
// returns <string>

str = 'good morning';
out = stickycase( 'good morning', 0.8 );
// returns <string>

Examples

var stickycase = require( '@stdlib/string/base/stickycase' );

var str = 'Hello World!';
var out = stickycase( str );
// returns <string>
// returns <string>

str = 'I am a tiny little teapot';
out = stickycase( str );
// returns <string>

str = 'with big problems';
out = stickycase( str, 0.1 );
// returns <string>

str = 'To be, or not to be: that is the question.';
out = stickycase( str, 0.9 );
// returns <string>

str = 'isMobile';
out = stickycase( str );
// returns <string>
Did you find this page helpful?