Trying to call my function


#1

Here are my instructions:
Call your function and pass in userChoice and computerChoice as your two arguments.

Here is my code in its entirety; NOTE: it says wrong syntax

var userChoice = prompt("Do you choose rock, paper or scissors?");
var computerChoice = Math.random();
if (computerChoice < 0.34) {
	computerChoice = "rock";
} else if(computerChoice <= 0.67) {
	computerChoice = "paper";
} else {
	computerChoice = "scissors";
} console.log("Computer: " + computerChoice);
var compare = function(choice1, choice2) {
    if (choice1 === choice2) {
        return "The result is a tie!";
    }
    else if (choice1 === "rock") {
        if (choice2 === "scissors") {
            return "rock wins";
        }
    else {
        return "paper wins";
    }
}
    else if (choice1 === "paper") {
        if (choice2 === "rock") {
    if (computerChoice === "rock") {
        return "rock dominates";
    }
    else if (computerChoice === "scissors") {
        return "scissors slice to victory!";
    }
    else {
        return "paper takes the cake";
    }
}
    
            return "paper wins";
        }
        else {
            return "scissors wins";
        }
    }
};

#2

Hey @objectmaster13146 You added a extra bracket there accidently at the end. just delete the bracket at the end of else here(last part):

 else {
        return "scissors wins";
    }
} <<<---- This one

And you should be fine! If your not pls reply saying so!


#3

i just got this message after deleting the bracket

Oops, try again. Your code returned 'scissors wins' instead of 'undefined' when the inputs are scissors and rock


#4

Hmm ok let me check I will edit for anwser


#5

Whitch one are you on since if you are on part 8, you need much more coding in the compare function...


#6

The stuff before is ok but here it gets weird. First do not use computerChoice in the function you assign this value when you call the function so

    if (choice2 === "rock") {
   if (computerChoice === "rock") {

do pretty much the same in the end. And then the nesting gets really out of hand. Better have a look at how you built the rock case and do something similar to this.