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


#1

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);

My Math.random seems fine but still get an error.can somebody help to point out where I might have done something wrong.


#2

Oh ok, seems like you're ahead of the exercise. This error is thrown if computerChoice is not a number. And in your case it is not as you've already converted it into a string. This is ok but for the next exercise, for this one it is expected to be a number.


#3

Hi Haxor 789, should it have been var computerChoice = Math.random(0,1);

thanks


#4

Just

var computerChoice = Math.random();

afaik it doesn't have any parameters and the range 0 to 1 is the default anyway.


#5

thanks.A problem with 7/9

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")
              return "paper wins";
         }
         else {
             return "scissors wins";
         }

Oops, try again. There was a problem with your syntax.

have been doing this since a few days not resolved syntax problem.


#6

The idea is that you have a look at choice1 first and then nest the 2 possible ways left for choice2 and example can be found in the hint of 6/9