String.prototype.reverse = function() { var a = this.split(""); a.reverse(); return a.join("");};
var myText = "Hello Ultrashock";trace(myText); // output: Hello Ultrashock myText = myText.reverse();trace(myText);// output: kcohsartlU olleH
Array.prototype.shuffle = function() { var a = [].concat(this); var i = a.length; var n; while (i--) { n = Math.floor(Math.random() * a.length); this[i] = a.splice(n, 1); } }
var myItems = ["apple", "banana", "cherry", "doughnut"];trace( myItems ); // output: apple,banana,cherry,doughnut myItems.shuffle();trace( myItems ); // output: doughnut,banana,apple,cherry