If I put Rock and the computer says Paper it will return "Its a Draw" and the values being both equal when they have the same type but a different value im slightly confused why this is happening at first i thought it was because i was using == and not === but the issue is still occurring. i want "ROCK" === "PAPER" to return false .
function getComputerChoice() {
randomnum = Math.floor(Math.random() * 3 + 1)
console.log(randomnum)
switch (randomnum) {
case 1:
return "ROCK"
break
case 2:
return "PAPER"
break
case 3:
return "SCISSCORS"
break
}
}
function game() {
console.log(getComputerChoice())
const playerSelection = prompt("Rock , Paper , SCISSCORS?").toUpperCase()
const ComputerSelection = getComputerChoice().toUpperCase()
function playRound(playerSelection, ComputerSelection) {
console.log(playerSelection === ComputerSelection)
if (playerSelection === ComputerSelection) {
return "Its A Draw"
}
if (playerSelection == "ROCK" && ComputerSelection == "SCISSCORS") {
return "You Won"
}
if (playerSelection == "ROCK" && ComputerSelection == "Paper") {
return "You Lose"
}
if (ComputerSelection == "ROCK" && playerSelection == "SCISSCORS") {
return "You Lose"
}
if (ComputerSelection == "ROCK" && playerSelection == "Paper") {
return "You Won"
}
if (playerSelection == "Paper" && ComputerSelection == "SCISSCORS") {
return "You Lost"
}
if (playerSelection == "Paper" && ComputerSelection == "Rock") {
return "You Won"
}
if (ComputerSelection == "Paper" && playerSelection == "SCISSCORS") {
return "You Won"
}
if (ComputerSelection == "Paper" && playerSelection == "Rock") {
return "You Lost"
}
if (playerSelection == "SCISSCORS" && ComputerSelection == "ROCK") {
return "You Lost"
}
if (playerSelection == "SCISSCORS" && ComputerSelection == "PAPER") {
return "You Won"
}
if (ComputerSelection == "SCISSCORS" && playerSelection == "ROCK") {
return "You Won"
}
if (ComputerSelection == "SCISSCORS" && playerSelection == "PAPER") {
return "You Lost"
}
}
console.log(playerSelection + ComputerSelection + playRound())
}
game()