Possible to define boolean value of "rock","paper", and "scissors"?


I haven't been able to find anything on this so far but essentially what I want to do is tell the program that:

 "rock" > "scissors"
 "scissors" > "paper"
 "paper" > "rock"
  1. to condense and possibly simplify my code. 2. To help create a "score keeping" method that could theoretically look something like:
var score1 = 0
var score2 = 0
if (choice1 > choice2)
else if (choice1 < choice2)
if (score1 >= 10)
    console.log("you've won the game!");
else if (score2 >=10);
    console.log("You've lost the game.  Better luck next time");
compare(userChoice, computerChoice);

I created a function at the top of the code for getting the choices of both the user and computer so that when there is a tie I can continue the game without it ending..

The code I have written here is incomplete but it should give a decent idea of what I'd like to be able to do to my game though I'm not sure that it is even possible.

All input will be appreciated. Thanks in advance.


Integrate your desired scoring into...

What you want is a loop-construct...
create the getUserChoice function using return-statement
create the getComputerChoice function using return-statement
creat the compare function using return-statement

As you are using return-statements you call the compare-function
var theResult = compare(userChoice,computerChoice);
and thus having the =result= of the game in the theResult variable


var playTheGame =function() {
    var playAgain =true;
    var userChoice="";
    var computerChoice="";
    var theResult="";

   while (playAgain) {

       //execute the pre-declared getUserChoice-function
       var userChoice = getUserChoice();
       console.log("User choice is " + userChoice);

        //execute the pre-declared getComputerChoice-function
        var computerChoice = getComputerChoice();
        console.log("Computer choice is " + computerChoice);

        //execute the compare-function and capture the-result
        theResult = compare(userChoice,computerChoice);
        console.log("The result is " + theResult);

    if (theResult === "It is a tie!") {
       playAgain = true;
    } else {
      playAgain = false;

    //end of -while- loop is reached, and if VALUE of playAgain === true
    // the loop will start over
    } //closing the while-loop
 }; //closing the function-body of playTheGame

// call the function playTheGame


@leonhard_wettengmx_n Thank you for giving me the answer without giving me THE answer. Your post inspired some critical thinking that, in the end, allowed me to finish my game so that it will keep score and also now displays:
1. Both the User's and Computer's choices.
2. Whether the User "Won", "Lost", or "Tied" that round.
3. What the current score is for both the User and the Computer.
4. Whether the User won or lost the game.

And of course it now also ends when one player reaches a score of 10. I'm sure that my code can probably be condensed a bit from what it currently is but I am happy that the game is working the way I wanted it to. Thank you very much for your input.