Skip to content

Instantly share code, notes, and snippets.

@NicholasMurray
Created March 18, 2013 17:06
Show Gist options
  • Save NicholasMurray/5188866 to your computer and use it in GitHub Desktop.
Save NicholasMurray/5188866 to your computer and use it in GitHub Desktop.
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