Can't get my score counter to work on rock paper scissors

This is my code for one round of Rock-Paper-Scissors. It is purely the Java script (I deleted the Script tag so as to get it to copy on this dialog box). The issue with it is that I cannot get the score counter to return the appropriate values (it always returns the originally assigned values of zero). The variables relevant to the counter are winLose, playerScore and computerScore. The functions relevant to the score counter are playerCount and computerCount. Any suggestions are mightily appreciated.

let winLose = false;
let playerScore = 0;
let computerScore = 0;
function game(playerScore, computerScore) {
for (i = 0; i < 5; i++) {
    var select = prompt("Pick either rock, paper or scissors.");
    let playerSelection = select.toLowerCase();
    function computerPlay () {  
        let selectRandom = [Math.floor(Math.random() * 10) + 1]
        if (selectRandom <= 3) {
            return "rock"; }
            else if (selectRandom <= 6) {
            return "paper"; }
            else if (selectRandom >6) {
            return "scissors"; }
let computerSelection = computerPlay(); 

function playRound(playerSelection, computerSelection) {
if (playerSelection == computerSelection) {
    return "It's a match!"; }
    else if ((playerSelection == "rock") && (computerSelection == "paper")) {
    return "You lose! Paper beats rock.";
    return winLose = false; }
    else if ((playerSelection == "rock") && (computerSelection == "scissors")) {
    return "You win! Rock beats scissors."; 
    return winLose = true; }
    else if ((playerSelection == "paper") && (computerSelection == "rock")) {
    return "You win! Paper beats rock";
    return winLose = true; }
    else if ((playerSelection == "paper") && (computerSelection == "scissors")) {
    return "You lose! Scissors beat paper.";
    return winLose = false;  }
    else if ((playerSelection == "scissors") && (computerSelection == "rock")) {
    return "You lose! Rock beats scissors"; 
    return winLose = false;}
    else if ((playerSelection == "scissors") && (computerSelection == "paper")) {
    return "You win! Scissors beat paper.";
    return winLose = true; }
function playerCount(winLose) {
    if (winLose == true) {
    playerScore++; }
function computerCount(winLose){
    if (winLose == false) {
    computerScore++; }
console.log(playRound(playerSelection, computerSelection)); 
console.log("Player Score" + " " + playerCount(winLose) + " , " + "Computer Score" + " " + computerCount(winLose));

Please paste your code in here (then save & share with us) or somewhere similar so that we exclude the possibility that there are other issues in your code:

Thank you Eduardo06p. I have now pasted the entire javascript code in the dialog box. Hope you can help me with this.

I’ll try to help you, but I have been busy recently.
I recommend that you paste the entire project into the site I provided you with.

I am not seeing a prompt pop up, nor do I see code for it. Sorry if I sound a bit hesitant, I promise you it makes things easier for both of us, because we will be looking at the exact same files :}

you can’t have two returns in the same block in a function, the moment the first hits you will exit the function.

              return 'You lose! Rock beats scissors';
              return (winLose = false);

Only the first will execute.
Hope that helps.

1 Like

Thank you. Yes, that solved the issue.