Skip to content

Instantly share code, notes, and snippets.

@tunnckoCore
Forked from westc/typoglycemia.js
Created February 22, 2015 21:46
Show Gist options
  • Save tunnckoCore/398939f40c345ee211a6 to your computer and use it in GitHub Desktop.
Save tunnckoCore/398939f40c345ee211a6 to your computer and use it in GitHub Desktop.
function scramble(input) {
return input.replace(/\b(\w)(\w{2,})(\w)\b/g, function(all, a, b, c) {
return a
+ b.split('').sort(function(){return Math.random()-.2}).join('')
+ c;
});
}
input = prompt("Enter the message you want scrambled:");
console.log(scramble(input));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment