Please, Help! Everything is correct imho


#1

https://www.codecademy.com/courses/javascript-beginner-en-Bthev-mskY8/0/3?curriculum_id=506324b3a7dffd00020bf661

Oops, try again. Did you set var computerChoice = Math.random() ? The capital 'M' in 'Math' is important!


var userChoice = prompt("Your choice?");
console.log("You:"+userChoice);
var computerChoice = Math.random();
if(computerChoice <= 0.33){
    computerChoice = "scissors";
    }
else if(computerChoice>0.33 && computerChoice<=0.66){
    computerChoice = "paper";
    }
else if(computerChoice>0.66){
    computerChoice = "rock";
    }
console.log("Computer:" + computerChoice);
var compare = function (choice1, choice2){
    if(choice1===choice2){
        return "Tie!";}
    else if(choice1 === "rock"){
        if(choice2 ==="scissors"){
            return "rock win!";}
        else{
            return "paper win!";}}
    else if(choice1 === "paper"){
        if(choice2 === "rock"){
            return "paper win!";}
        else{
            return "scissors win!";}
        }
    else if(choice1 === "scissors"){
        if(choice2==="paper"){
            return "scissors win!";}
        else{
            return "rock win!";
            }
            }
            
    }
compare(userChoice,computerChoice);


#2

Your compare function is missing a curly bracket in the end, I guess.


#3

i added on curly bracket, shows "unexpected token }"


#4

i think mistake is not about brackets)


#5

Nope, I wrote wrong thing :slight_smile:


#6

Why you use "choice1, choice2" if you haven't declare it yet?


#7

Check what value it has by the time your code has finished.
What do instructions/error message say it should refer to?
What value does it refer to?


#8

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.