Rock Paper Scissors Lizard Spock in JQuery I wrote a little Javascript rock/paper/scissors/lizard/spock game and when the user clicks the button to make their choice from the five options, I choose the computer's randomly  and then compare the two to find a winner and output the result. It works, but I have the feeling that the findWinner function can be a lot shorter or more elegant. I'm trying to improve my Javascript and jQuery and was hoping for someone to help me with next steps here:.

function findWinner(choiceA,choiceB) {
  if (choiceA == choiceB) {
    return "It's a tie!"; 
  }

  if (choiceA == 'Rock') {
    if (choiceB == 'Lizard' || choiceB == 'Scissors') {
      return "You win!";
    }
    else if (choiceB == 'Spock' || choiceB == 'Paper') {
      return choiceB;
    }
  }
  else if (choiceA == 'Paper') {
    if (choiceB == 'Rock' || choiceB == 'Spock') {
      return "You win!";
    }
    else if (choiceB == 'Scissors' || choiceB == 'Lizard') {
      return "Computer wins :( "; 
    }
  }
  else if (choiceA == 'Scissors') {
    if (choiceB == 'Paper' || choiceB == 'Lizard') {
      return "You win!";
    }
    else if (choiceB == 'Spock' || choiceB == 'Rock') {
      return "Computer wins :( "; 
    }
  }
  else if (choiceA == 'Lizard') {
    if (choiceB == 'Paper' || choiceB == 'Spock') {
      return "You win!";
    }
    else if (choiceB == 'Rock' || choiceB == 'Scissors') {
      return "Computer wins :( "; 
    }
  }
  else if (choiceA == 'Spock') {
    if (choiceB == 'Rock' || choiceB == 'Scissor') {
      return "You win!";
    }
    else if (choiceB == 'Paper' || choiceB == 'Lizard') {
      return "Computer wins :( "; 
    }
  }
}


This just seems very repetitive, but I'm not sure where to go next with it.
Write down the rules in an object. If an object contains a key, it means it can beat it.

Also, you're writing a javascript game, not jQuery. jQuery is a javascript library.



var rules = {
  rock: {
    scissors: true,
    lizard: true
  },
  scissors: {
    paper: true,
    lizard: true
  },
  lizard: {
    paper: true,
    spock: true
  },
  spock: {
    rock: true,
    scissors: true
  },
  paper: {
    rock: true,
    spock: true
  }
};

function play(opt1, opt2) {
  if (opt1 === opt2) {
    return "Draw";
  }

  if (rules[opt1][opt2]) {
    return "You win";
  }

  return "You loose";
}

console.log(play("rock", "scissors"));
console.log(play("paper", "paper"));
console.log(play("lizard", "spock"));