Created
March 18, 2013 17:06
-
-
Save NicholasMurray/5188866 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
var choiceArray = ['rock', 'paper', 'scissors']; | |
var humanChoice = ''; | |
var computerChoice = ''; | |
var winner = ''; | |
$('#play-game').click(function() { | |
computerChoice = choiceArray[Math.floor(Math.random() * choiceArray.length)]; | |
humanChoice = $('input:radio[name=human-choice]:checked').val(); | |
if ((humanChoice === '') || humanChoice === undefined) { | |
alert('Please choose an object to play!'); | |
} else { | |
$('#computer-choice').text(computerChoice); | |
var winner = theWinnerIs(humanChoice, computerChoice) | |
$('#winner').text(winner); | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment