// Initializing Variables var userChoice = prompt("Do you choose rock, paper, scissors, lizard, or spock?"); var choices = ["rock", "paper", "scissors", "lizard", "spock"]; var computerChoice = choices[ Math.floor( Math.random() * choices.length ) ]; // Function that compares the two values function compare( choice1, choice2 ) { var rock = { defeats: ["scissors", "lizard"], loses: ["paper", "spock"], name: ["rock"] }; var paper = { defeats: ["rock", "spock"], loses: ["scissors", "lizard"], name: ["paper"] }; var scissors = { defeats: ["paper", "lizard"], loses: ["rock", "spock"], name: ["scissors"] }; var lizard = { defeats: ["paper","spock"], loses: ["rock", "scissors"], name: ["lizard"] }; var spock = { defeats: ["scissors", "rock"], loses: ["lizard", "paper"], name: ["spock"] }; var perms = [rock, paper, scissors, lizard, spock]; var plen = perms.length; for(i=0; iUser selects: " + userChoice + ""); document.write("
Computer selects: " + computerChoice + "
"); document.write("
Results are: " + compare(userChoice, computerChoice) + "
");