Last active
August 29, 2015 14:02
-
-
Save westc/7df66077dccecda1e897 to your computer and use it in GitHub Desktop.
Message Scrambler - Proof that typoglycemia allows us to read scrambled messages.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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()-.5}).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
i think it should (it would be) better if it is
.2
not.5