press the refress button to see random gems alert
gems.length has been commented out replace with number 3
<! DOCTYPE HTML>
<html>
<head>
<title>looparray</title>
<script type="text/javascript">
var gems=new Array("diamond","ruby","saphire","emerald");
gemItem = Math.round(Math.random()*3);//gems.length
alert(gems[gemItem]);
</script>
</head>
<body>
</body>
</html>
my game studies
Monday, June 18, 2012
Random function generator with array
im currently on intersession til about july 7.i desided to use this time to work on some fundamentals.today i wrote a code that randomly selects an item from an array using the random function. it works great with a number but when i use the get length function of the array, it gives one undefined value.still trying to figure that out.anyway if anyone want to try to figure it out i will post it here
welcome to my game creating blog
hi welcome to my blog.my name is kevin and im a student at new england tech.i studie video game design and simulation and have devoted this blog to my studies . i will post my experiments on this blog as well as my findings on what works for me. fell free to comment.
Subscribe to:
Comments (Atom)