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

189
Views
why is it when i run the code doesnt match with my code

(im a beginner and sorr for my bad english) im just messing around with else, if statement and i am working on a rock paper scissors game. then i do not know whats wrong with my code. when i run it sometimes it dont print out the console log like i wanted. for example, P1 (player 1) picks paper and P2 picks rock, then it will say that its a tie. please help me

code:

var player1 = prompt("(P1) rock, paper, or scisors? : ");
var player2 = prompt("(P2) rock, paper, or scisors? : ");

if (player1 === "rock", player2 === "paper"){
console.log("P2 WINS!")
} else if (player1 === "rock", player2 === "scissors"){
console.log("P1 WINS!")
} else if (player1 === "rock", player2 === "rock"){
console.log("TIE!")
} else if (player1 === "paper", player2 === "rock"){
console.log("P1 WINS!")
} else if (player1 === "paper", player2 === "scissors"){
console.log("P2 WINS!")
} else if (player1 === "paper", player2 === "paper"){
console.log("TIE!")
} else if (player1 === "scissors", player2 === "rock"){
console.log("P2 WINS!")
} else if (player1 === "scissors", player2 === "paper"){
console.log("P1 WINS!")
} else {
console.log("TIE!")
};
about 4 years ago · Juan Pablo Isaza
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!