Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

178
Views
I'am making a Rock, Paper, Scissors game and the winnerCheck function doesn't work

// Score //

let computerScore = 0 let playerScore = 0

function playRound() {
       
    
    //My "choice"// 
    
        let Answer = prompt(`Do you choose Rock,Paper or Scissors ?`).toLowerCase();
            console.log(Answer);
                                
    function computerPlay() {
     computerPlay = Math.floor(Math.random() * 3)
        
        if(computerPlay === 0) { 
            console.log("rock"); 
        } else if (computerPlay === 1) {
            console.log("paper"); 
        } else if (computerPlay === 2){
            console.log("scissors"); 
        }      
    }
     computerPlay()
        //The conditions for the game//
     
        if(Answer == "rock" && computerPlay === 0){
          return ("Draw");   
         } 
          else if(Answer == "rock" && computerPlay === 1 ){
               computerScore += 1
               return("You lost");     
            }
        
          else if(Answer == "rock" && computerPlay === 2){
                playerScore += 1
                return("You won");
            }
            
       if(Answer == "paper" && computerPlay === 0 ) {  
            playerScore += 1
            return("You Won!");   
          }
         else if(Answer == "paper" && computerPlay === 1) { 
            return("Draw");
        }
       else if (Answer == "paper" && computerPlay === 2) {
            computerScore += 1
            return("You Lost!");
             
          }
        if(Answer == "scissors" && computerPlay === 0) { 
                computerScore += 1
                return("You Lost!")
         } 
          else if(Answer == "scissors" && computerPlay === 1) {
                playerScore += 1
                return("You Won!");
               
            }
         else if(Answer == "scissors" && computerPlay === 2) { 
                return("Draw!");        
        }
    }

//so this fucnction doesn't work...| How can I make it work?? V// function winnerCheck() { if (computerScore === 5){ console.log("Player won!") } else if (playerScore === 5) { console.log("Computer won!"); } }
winnerCheck() playRound()

about 4 years ago · Santiago Trujillo
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!