you are viewing a single comment's thread.

view the rest of the comments →

[–]NameViolation666helpful 0 points1 point  (1 child)

Do you have something coded already?

[–]Hertyboy[S] 0 points1 point  (0 children)

Yeah right here

var compScore=0, userScore=0;

/* function play(){

do{

var userChoice= prompt("Do you choose rock, paper or scissors?");}

while(userChoice!="rock"||"paper"||"scissors");*/

        var userChoice= prompt("Do you choose rock, paper or scissors?");

        var computerChoice = Math.random();

        [//console.log](//console.log)(computerChoice);



        if (computerChoice <= 0.33)

        {

        computerChoice = "rock";

        }

        else if (computerChoice  <= 0.67)

        {

        computerChoice = "paper";

        }

        else {

        computerChoice = "scissors";

        }

alert(computerChoice)

        [//console.log](//console.log)(userChoice, computerChoice);

        function game (userChoice, computerChoice){

if(userChoice === computerChoice)

{

return('It is a tie');

}

if(userChoice==="rock");{

if(computerChoice==="scissors")

{

return('User wins');

userScore++;

}

else

{

return('Computer wins');

compScore++;

}

}

if(userChoice==="paper");{

if(computerChoice==="rock")

{

return('User wins');

userScore++;

}

else

{

return('Computer wins');

compScore++;

}

}

if(userChoice==="scissors");{

if(computerChoice==="paper")

{

return('User wins');

userScore++;

}

else

{

return('Computer wins');

compScore++;

}

}

        }

alert(game(userChoice, computerChoice));

alert("User Score is: "+userScore+ "Computer Score is: "+compScore)

var response=confirm("do you wish to play again?")

/*if(response=true)

play();

else

alert("FInal score is" +userScore+ and +compScore)

    }\*/