samedi 19 novembre 2016

My tag will not work with my function()

   var rock = 1;

   var paper = 2;

   var scissors = 3; 

   var spock = 4;

   var lizard = 5;

function Game() {

   var ComputerChoice = ((Math.Random() * 5) + 1);

   var UserChoice = ""

   if (UserChoice == ComputerChoice){

      document.getElementById("user").innerHTML = "Its a tie! Your opponent also chose" + ComputerChoice;

   } 


      if (ComputerChoice == 1){
      return "Rock"
   }

      if (ComputerChoice == 2){
      return "Paper"
   }

      if (ComputerChoice == 3){
      return "Scissors"
   }

      if (ComputerChoice == 4){
      return "Spock"
   }

      if (ComputerChoice == 5){
      return "Lizard"

   }

 if (ComputerChoice == 1 && UserChoice == 2){

     document.getElementById("user").innerHTML="You won! The computer chose" + ComputerChoice;

 }



}

Aucun commentaire:

Enregistrer un commentaire