This is probably way too much code for such a simple game.
How do I do if comparisons without a function? To make it work, I made a function withe the (domath) parameter. But I don’t actually need that parameter to do anything, it was just the only way I knew how to continue with if, if else, else, statements.
You’ll see the end line is undefined, since (domath) is not defined anywhere. How do I fix this?
var myMove = prompt(“1,2,3…rock, paper, scissors?”)
console.log(“You throw” + " " + myMove)
var Comp = Math.floor((Math.random() * 3) + 1);{
if (Comp == 1){
Comp = “rock”;
}
else if (Comp == 2){
Comp = “paper”;
}
else {
Comp = “scissors”;
}
}
console.log(“RPSBot throws” + " " + Comp)
var Results = function(domath){
if (myMove == “rock”){
if (Comp == “rock”){
console.log(“It’s a tie”)
}
else if (Comp == “scissors”) {
console.log(“Your rock crushes scissors!”)
}
else {
console.log(“Paper covers your rock”)
}}
else if (myMove == “paper”){
if (Comp == “paper”){
console.log(“It’s a tie”)
}
else if (Comp == “rock”){
console.log(“Your paper covers rock”)
}
else {
console.log(“Scissors cut your paper”)
}}
else {
if (Comp == “scissors”){
console.log(“It’s a tie”)
}
else if (Comp == “paper”){
console.log(“Your scissors cuts paper!”)
}
else {
console.log(“Rock crushes your scissors”)
}}
}
console.log(Results(“domath”));