<commit_before>////////////////////////////////////////////////
/*   Provided Code - Please Don't Edit   */
////////////////////////////////////////////////
'use strict';

function getInput() {
    console.log("Please choose either 'rock', 'paper', or 'scissors'.")
    return prompt();
}
function randomPlay() {
    var randomNumber = Math.random();
    if (randomNumber < 0.33) {
        return "rock";
    } else if (randomNumber < 0.66) {
        return "paper";
    } else {
        return "scissors";
    }
}
////////////////////////////////////////////////
/*           Write Your Code Below            */
////////////////////////////////////////////////

function getPlayerMove(move) {
    // Write an expression that operates on a variable called `move`
    var move;
    // If a `move` has a value, your expression should evaluate to that value.
    if (move === null) { getInput();} else { playerMove = move;}  
    // However, if `move` is not specified / is null, your expression should equal `getInput()`.
    return playerMove;
}

function getComputerMove(move) {
    // Write an expression that operates on a variable called `move`
    var move;
    // If a `move` has a value, your expression should evaluate to that value.
    if (move === null) { randomPlay(); } else { computerMove = move; }
    // However, if `move` is not specified / is null, your expression should equal `randomPlay()`.
    return computerMove;
}

function getWinner(playerMove,computerMove) {
    var winner;
    // Write code that will set winner to either 'player', 'computer', or 'tie' based on the values of playerMove and computerMove.
    // Assume that the only values playerMove and computerMove can have are 'rock', 'paper', and 'scissors'.
    // The rules of the game are that 'rock' beats 'scissors', 'scissors' beats 'paper', and 'paper' beats 'rock'.
    /* YOUR CODE HERE */
    return winner;
}

function playToFive() {
    console.log("Let's play Rock, Paper, Scissors");
    var playerWins = 0;
    var computerWins = 0;
    // Write code that plays 'Rock, Paper, Scissors' until either the player or the computer has won five times.
    /* YOUR CODE HERE */
    return [playerWins, computerWins];
}
<commit_msg>Code for function which finds a winner in rockpaperscissors.js file<commit_after>////////////////////////////////////////////////
/*   Provided Code - Please Don't Edit   */
////////////////////////////////////////////////
'use strict';

function getInput() {
    console.log("Please choose either 'rock', 'paper', or 'scissors'.")
    return prompt();
}
function randomPlay() {
    var randomNumber = Math.random();
    if (randomNumber < 0.33) {
        return "rock";
    } else if (randomNumber < 0.66) {
        return "paper";
    } else {
        return "scissors";
    }
}
////////////////////////////////////////////////
/*           Write Your Code Below            */
////////////////////////////////////////////////

function getPlayerMove() {
    // Write an expression that operates on a variable called `move`
    var move;
    var playerMove;
    move = getInput();

    // However, if `move` is not specified / is null, your expression should equal `getInput()`.
    if (move === null) {
        getInput();
    }
    // If a `move` has a value, your expression should evaluate to that value.
    else {
        playerMove = move;
    }

    return playerMove;
}

function getComputerMove() {
    
    // Write an expression that operates on a variable called `move`
    var move;
    var computerMove;
    move = randomPlay();

    // However, if `move` is not specified / is null, your expression should equal `randomPlay()`.
    if (move === null) {
        computerMove = randomPlay();
    }
    // If a `move` has a value, your expression should evaluate to that value.
    else {
        computerMove = move;
    }
    
    return computerMove;
}

function getWinner(playerMove,computerMove) {
    var winner;
    // Write code that will set winner to either 'player', 'computer', or 'tie' based on the values of playerMove and computerMove.
    // Assume that the only values playerMove and computerMove can have are 'rock', 'paper', and 'scissors'.
    // The rules of the game are that 'rock' beats 'scissors', 'scissors' beats 'paper', and 'paper' beats 'rock'.
    /* YOUR CODE HERE */
    // console.log("player has " + playerMove);
    // console.log("computer has " + computerMove);
    
    if ((playerMove == "rock") || (playerMove == "paper") || (playerMove == "scissors"))
    {
        if ((playerMove == "rock") && (computerMove == "scissors"))     {
            winner = "player" + " wins en 1!!!!";            
        }
        else if ((playerMove == "paper") && (computerMove == "rock"))
        {
            winner = "player" + " wins en 2!!!!";
        }
        else if ((playerMove == "scissors") && (computerMove == "paper"))
        {
            winner = "player" + " wins en 3!!!!";
        }
        else if ((playerMove == "rock") && (computerMove == "paper"))
        {
            winner = "computer" + " wins en 4!!!!";
        }
        else if ((playerMove == "paper") && (computerMove == "scissors"))
        {
            winner = "computer" + " wins en 5!!!!";
        }
        else if ((playerMove == "scissors") && (computerMove == "rock"))
        {
            winner = "computer" + " wins en 6!!!!";
        }
        else{
            winner = "tie" + " wins en 7!!!!";
        }
    }
    else{
        winner = "Wrong choice! Try again!";
    }

    return winner;
}

function playToFive() {
    console.log("Let's play Rock, Paper, Scissors");
    var playerWins = 0;
    var computerWins = 0;
    // Write code that plays 'Rock, Paper, Scissors' until either the player or the computer has won five times.
    /* YOUR CODE HERE */
    return [playerWins, computerWins];
}

var p1;
var p2;
p1 = getPlayerMove();
p2 = getComputerMove();

var winner;
winner = getWinner(p1,p2);
console.log(winner);
{'fraction_non_alphanumeric': 0.18784438136583737, 'fraction_numerical': 0.004842210719652696, 'mean_word_length': 1.9845540607872447, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '212136', 'n_tokens_mistral': 1688, 'n_tokens_neox': 1616, 'n_words': 597}