Skip to content

ProtoString shuffle() Method

Seth Clydesdale edited this page Jun 1, 2015 · 2 revisions

<< Back to Position Methods

Examples

Shuffling the characters of a string.

'string'.shuffle(); // returns 'gitsrn'
'javascript'.shuffle(); // returns 'ticaajvsrp'

Passing a number as the parameter will shuffle the string n times.

'string'.shuffle(3); // returns 'rgsnit'
'javascript'.shuffle(4); // returns 'vipaartsjc'

Description

The shuffle method shuffles the characters of a string, rendering it unreadable. A shuffled string can then be unshuffled with the unshuffle() method, or by continually shuffling a string's characters.

Syntax

String.shuffle(n);

Parameters

Parameter Description
n A number that specifies the number of times a string should be shuffled. Defaults to 1 if left undefined.
Clone this wiki locally