Stuck at Rock Paper Scissors Game Computer Choice: Part 1


#1

Hi guys, I am stuck at Computer Choice Part 1 of Rock, Paper, Scissors Game, please help!
I keep getting this error "Did you set var computerChoice = Math.random() ? The capital 'M' in 'Math' is important!:
here is my code below:

var rock = ["Tie", "Paper Wins!", "Rock Wins!"];
var paper = ["Paper Wins!", "Tie", "Scissors Wins!"];
var scissors = ["Rock Wins!", "Scissors Wins!", "tie"];

for (var i = 0, n = 1; i < n; i++) {
    var userChoice = prompt("Do you choose rock, paper or scissors?");
    var computerChoice = Math.random();
    console.log(computerChoice);
    console.log("You chose" + " " + userChoice + ".");
if (computerChoice <0.34) 
{
computerChoice = "rock";
}else if(computerChoice <=0.67)
{
computerChoice = "paper";
}
else
{
computerChoice = "scissors";
}
    if (userChoice == "rock") {
        console.log(rock[computerChoice]);
    } else if (userChoice == "paper") {
        console.log(paper[computerChoice]);
    } else {
        console.log(scissors[computerChoice]);
    }
    n += confirm("Do you want to keep playing?");
}

#2

putting too much code also causes problem, the exercise check computerChoice has a value between 0 and 1


#3

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