const choices = ['rock', 'paper', 'scissors'];

computerPlay = () => {
    return choices[Math.floor(Math.random() * 3)];
};

const computerSelection = computerPlay();
const playerSelection = prompt('Rock, paper, or scissors?', 'rock').toLowerCase();
let playerScore = 0;
let computerScore = 0;
let tie = 0;

playRound = (playerSelection, computerSelection) => {
    const result = [`${playerSelection} beats ${computerSelection}. Player wins!`, `${computerSelection} beats ${playerSelection}. Player loses`, `It's a tie!`];
    
    
    if ((playerSelection === 'rock' && computerSelection === 'paper') || 
    (playerSelection === 'scissors' && computerSelection === 'rock') || 
    (playerSelection === 'scissors' && computerSelection === 'rock')) {
        console.log(result[1]);
        return result[1];
    } else if ((playerSelection === 'rock' && computerSelection === 'scissors') || 
    (playerSelection === 'paper' && computerSelection === 'rock') || 
    (playerSelection === 'scissors' && computerSelection === 'paper')) {
        console.log(result[0]);
        return result[0];
    } else {
        console.log(result[2]);
        return result[2];
    }
}

game = () => {
    for (let i = 0; i < 5; i++) {
        playRound();
        
    }
        
    roundWin = () => {
        if (result[0]) {
            playerScore++;
        } else if (result[1]) {
            computerScore++;
        } else {
            tie++;
        }
    }

    announceWinner = () => {
        if (playerScore + computerScore + tie > 5) {

        }
    }
}
game();

    
Run Pen

External CSS

This Pen doesn't use any external CSS resources.

External JavaScript

This Pen doesn't use any external JavaScript resources.