A Pen by Mohammed Saifuddin on CodePen.
Last active
April 19, 2017 04:22
-
-
Save acesaif/05f44d170e9c60d197fd62a9c7665350 to your computer and use it in GitHub Desktop.
Rock Paper Scissors
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<link href="https://fonts.googleapis.com/css?family=Macondo" rel="stylesheet"> | |
<h1>ROCK - PAPER - SCISSORS</h1> | |
<h3> ... A Game by AceSaif ... </h3> | |
<h4>This game is completely powered by JavaScript which is a powerful Web Application Language.</h4> | |
<h4>Ergo I present this game as a tribute to every lad who plays this ...</h4> | |
<h5> ... Thank You ... </h5> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
alert("This Game is Rock - Paper - Scissors"); | |
alert("Give 'Rock / Paper / Scissors' as Your Choice"); | |
var userChoice = prompt("Rock or Paper or Scissors?"); | |
var computerChoice = Math.random(); | |
if (computerChoice < 0.34) { | |
computerChoice = "Rock"; | |
} else if (computerChoice <= 0.67) { | |
computerChoice = "Paper"; | |
} else { | |
computerChoice = "Scissors"; | |
} | |
alert("Computer's Choice: " + computerChoice); | |
function compare(choice1, choice2) { | |
if (choice1 === choice2) { | |
return alert("...The Result is a Tie!..."); | |
} | |
else if (choice1 === "Rock") { | |
if (choice2 === "Scissors") { | |
return alert("Rock Wins... You Win..."); | |
} else { | |
return alert("Paper Wins... Computer Wins..."); | |
} | |
} | |
else if (choice1 === "Paper") { | |
if (choice2 === "Rock") { | |
return alert("Paper Wins... You Win..."); | |
} else { | |
return alert("Scissors Wins... Computer Wins..."); | |
} | |
} | |
else if (choice1 === "Scissors") { | |
if (choice2 === "Paper") { | |
return alert("Scissors Wins... You Win..."); | |
} else { | |
return alert("Rock Wins... Computer Wins..."); | |
} | |
} | |
else { | |
alert("Please give Authenticate Input!"); | |
} | |
} | |
compare(userChoice, computerChoice); | |
var gameAgain = prompt("Want to Play Again?... Say - Yes / No -"); | |
if (gameAgain === "Yes") { | |
alert("Then Hit Refresh Button"); | |
} else if (gameAgain === "No") { | |
alert("... Do Your HomeWork ..."); | |
} else { | |
alert("Help Yourself!!!"); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
body { | |
background-color: green; | |
} | |
h1, h3, h4, h5 { | |
font-family: Macondo, cursive; | |
text-align: center; | |
} | |
h1 { | |
font-size: 100px; | |
} | |
h3 { | |
font-size: 50px; | |
font-style: italic; | |
} | |
h4 { | |
font-size: 25px; | |
} | |
h5 { | |
font-size: 35px; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment