Skip to content

Instantly share code, notes, and snippets.

@ashryanbeats
Created February 17, 2012 02:50
Show Gist options
  • Save ashryanbeats/1850112 to your computer and use it in GitHub Desktop.
Save ashryanbeats/1850112 to your computer and use it in GitHub Desktop.
Conditionals in Javascript Project
var die1 = Math.floor(Math.random()*6 + 1);
var die2 = Math.floor(Math.random()*6 + 1);
var score;
if(die1 === 1 || die2 === 1){
score = 0
} else {
if(die1 === die2){
score = die1+die2*2
} else {
score = die1+die2
}
}
console.log("You rolled a "+die1+" and a "+die2+" for a score of "+score);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment