Generate random numbes in a range : random : Math JAVASCRIPT TUTORIALS


JAVASCRIPT TUTORIALS » Math » random »

 

Generate random numbes in a range

















<html>
<head>
<title>die Roller</title>
<script>
var rollRaw = 0;
var rollBigger = 0;
var rollInt = 0;
var rollFinal = 0;
var result = "";

rollRaw = Math.random();
rollBigger = rollRaw * 6;
rollInt = Math.floor(rollBigger);
rollFinal = rollInt + 1;

result = "rollRaw: " + rollRaw + "n";
result += "rollBigger: " + rollBigger + "n";
result += "rollInt: " + rollInt + "n";
result += "rollFinal: " + rollFinal + "n";

alert(result);

</script>
</head>
<body>
</body>
</html>







HTML code for linking to this page:

Follow Navioo On Twitter

JAVASCRIPT TUTORIALS

 Navioo Math
» random