# str.shuffle()

[🔰 JS](../../../..) ⟩ [Types](../../../type) ⟩ [String](..) ⟩ [methods]()

{% tabs %}
{% tab title="string.shuffle()" %}
```javascript
/**
 * ⭐️ shuffleString()
 *    shuffle string
 * @param str [string] string to shuffle
 */
export function shuffleString(str){
    return shuffle(str.split('')).join('');
}

// ⭐️ string.shuffle()
String.prototype.shuffle = function(){
    return shuffleString(this);
}
```
{% endtab %}

{% tab title="⬆️ 需要" %}
* [randomInt()](../../num/random/randomint)
* [array.shuffle()](../../../builtin/arr/ext/arr.shuffle)
{% endtab %}

{% tab title="📗 參考" %}
* [x] DEV ⟩ [How to shuffle an array in JavaScript](https://dev.to/codebubb/how-to-shuffle-an-array-in-javascript-2ikj)
{% endtab %}
{% endtabs %}
