Whats wrong need help


#1

var UC = prompt("Do you choose rock, paper or scissors?");
var CC = Math.random(3);

if(CC < 3) {
CC = "rock";
}
else if(CC < 2) {
CC = "paper";
}
else {
CC = "scissors";
}

var compare = function(C1, C2) {

if(C1 === C2) {

confirm("The result is a tie");

}
else if(C1 === "rock") {

if(C2 === "scissors") {

    confirm("rock wins!");

}else {
        confirm("paper wins!");
    }

}
else if(C1 === "paper") {

if(C2 === "rock") {

    confirm("paper wins!");

}else {
        confirm("scissors wins!");
    }

}
else if(C1 === "scissors") {

if(C2 === "paper") {

    confirm("scissors wins!");

}else {
        confirm("rock wins!");
    }

}
else{
}
};


#2

Hello, I'm not sure what your variable CC is doing but, there isn't supposed to be anything withing the brackets of Math.random();

Also, your 1st if/else statement are incorrect try:
if (CC < 0.34) {
CC = "rock";
} else if(CC <= 0.67) {
CC = "paper";
} else {
CC = "scissors";
} console.log("Computer: " + CC);

In the code you were supposed to write, the variable CC would never be more than 1 so, in doing what you did, CC would be Rock, Paper and scissors, all at the same time. Try giving that a try.

Enjoy!


#3

Guess CC is a shortcut for computerChoice but you're right Math.random always generates a number between 0 and really close to one and adding an argument is not the correct way to increase the range of numbers. A possible way to do this would be to multiply a value: Math.random()*3.