4/9 Syntax Error "Rock, Paper, Scissors"


#1

var userChoice = prompt("Do you want to choose rock, paper, or scissors?");

var computerChoice = Math.random(0,1);

if (computerChoice <= 0.33)
{
    return "rock";
}
    else if (computerChoice >= 0.34 && computerChoice <= 0.66) 
{
    return "paper";
}
    else 
{
    return "scissors";
}

console.log(computerChoice);

Really not sure what I'm doing wrong here in terms of programming syntax. Anyone have any ideas?


#2

"return" is to be used inside functions.

you can try:

var userChoice = prompt("Do you want to choose rock, paper, or scissors?");

var computerChoice = Math.random(0,1);

if (computerChoice <= 0.33)
{
console.log("rock");
}
else if (computerChoice >= 0.34 && computerChoice <= 0.66) 
{
console.log("paper");
}
else 
{
console.log("scissors");
}

console.log(computerChoice);

#3

Yes that is the problem. But instead of just print them one should assign them back to computerChoice e.g.

computerChoice = "rock";

#4

Thanks for the help guys. I was able to complete it.