Skip to content

Instantly share code, notes, and snippets.

@liuderchi liuderchi/shuffle.js
Created Jan 22, 2018

Embed
What would you like to do?
shuffle a string in js
// https://stackoverflow.com/a/46545530/1618628
function shuffle = (str) => str.split('')
.map((a) => ({sort: Math.random(), value: a}))
.sort((a, b) => a.sort - b.sort)
.map((a) => a.value)
.join('')
console.log(shuffle('abbychui'))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.