Skip to content

Instantly share code, notes, and snippets.

Last active November 12, 2015 21:56
Show Gist options
  • Save anonymous/a0cd823a6be2d6bfbbac to your computer and use it in GitHub Desktop.
Save anonymous/a0cd823a6be2d6bfbbac to your computer and use it in GitHub Desktop.
JS Console Dice Roll // source http://jsbin.com/buboka
<!DOCTYPE html>
<html>
<head>
<title>JS Console Dice Roll</title>
</head>
<body>
<script id="jsbin-javascript">
/*
Dice Game
Directions: Make a program that randomly displays a number 1 through 6 to the console
Instructions:
1. Use Math.random to display a random number between 0 and 1
2. Multiply your Math.random function by 6
3. Use Math.floor to only display whole numbers between 0 and 5
4. Add the number one to Math.random to display a random number between 1 and 6
*/
//score = die
//To do: Insert you code here
// var die = Math.floor(Math.random()*6 + 1);
function die(){Math.floor(Math.random()*6 + 1);
var result =
//(prompt);
//prompt("Hi");
console.log("You rolled a + die");
</script>
<script id="jsbin-source-html" type="text/html">
<!DOCTYPE html>
<html>
<head>
<title>JS Console Dice Roll</title>
</head>
<body>
</body>
</html>
</script>
<script id="jsbin-source-javascript" type="text/javascript">/*
Dice Game
Directions: Make a program that randomly displays a number 1 through 6 to the console
Instructions:
1. Use Math.random to display a random number between 0 and 1
2. Multiply your Math.random function by 6
3. Use Math.floor to only display whole numbers between 0 and 5
4. Add the number one to Math.random to display a random number between 1 and 6
*/
//score = die
//To do: Insert you code here
// var die = Math.floor(Math.random()*6 + 1);
function die(){Math.floor(Math.random()*6 + 1);
var result =
//(prompt);
//prompt("Hi");
console.log("You rolled a + die");</script></body>
</html>
/*
Dice Game
Directions: Make a program that randomly displays a number 1 through 6 to the console
Instructions:
1. Use Math.random to display a random number between 0 and 1
2. Multiply your Math.random function by 6
3. Use Math.floor to only display whole numbers between 0 and 5
4. Add the number one to Math.random to display a random number between 1 and 6
*/
//score = die
//To do: Insert you code here
// var die = Math.floor(Math.random()*6 + 1);
function die(){Math.floor(Math.random()*6 + 1);
var result =
//(prompt);
//prompt("Hi");
console.log("You rolled a + die");
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment