Created
February 26, 2020 18:57
-
-
Save markcmarino/85bd382a968663adb989eab810d147e9 to your computer and use it in GitHub Desktop.
A sample anagram program...
This file contains 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 anagram(text) { | |
var a = text.split(""); | |
for (var i = 0; i < a.length; i += 1) { | |
var letter = a[i]; | |
var j = Math.floor(Math.random() * a.length); | |
a[i] = a[j]; | |
a[j] = letter; | |
} | |
return a.join(""); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment