What's wrong?


#1

Here is the code I wrote down but it says I didn't create the var computerChoice = Math.random(); which is strange because I did. Anyway here is the code:

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

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

Thank you anyways :wink:


#2

Reload your browser and try again.


#3

Seems to be ok so if it is for 4/9 I would agree with @oscarbjurestrand if it is for 3/9 then get rid of the if else aso (save them in a file somewhere for 4/9) and just console.log the number. The problem is that 3/9 expects a number so if you already got ahead and converted it into a string it assumes that you have no number because you counldn't use Math.random() correctly.


#4

Thank you very much :blush: thought it would still register the code. (feel really dumb thought :confused:)


#5

These lessons, like coding in general, expect specific inputs so that it knows what you're trying to do. Anything outside of perfection will error in some way. Just keep that in mind for the future :smiley: