An anagram is simply the letters of the word scrambled.
Try this demo, then see if you can guess how to write the code.
Put in a word and press enter to see an anagram.