Mon Sep 19, 2011 12:17 pm
<html>
<title>Shuffle Array</title>
<head>
<script language="JavaScript">
function Shuffle(arr) {
for(var j, x, i = arr.length; i; j = parseInt(Math.random() * i),
x = arr[--i], arr[i] = arr[j], arr[j] = x);
return arr;
};
function ShuffleArray()
{
var colorArr= Array("RED", "BLUE", "YELLOW");
suffcolor=Shuffle(colorArr);
// traverse array
for (key in suffcolor)
document.write("<br/>color value is " + suffcolor[key]);
}
</script>
</head>
<body>
<SCRIPT language="JavaScript">
ShuffleArray();
</SCRIPT>
</body>
</HTML>
Codemiles.com is a participant in the Amazon Services LLC Associates Program, an affiliate advertising program designed to provide a means for sites to earn advertising fees by advertising and linking to Amazon.com
Powered by phpBB © phpBB Group.