Computer Choice: Part 1


#1

Hi I need your help! I have following error message. Someone have a good idea?
Oops, try again. Did you set var computerChoice = Math.random() ? The capital 'M' in 'Math' is important!

var userChoice = prompt("Do you choose rock, paper or scissors?");
var computerChoice = Math.random();

console.log("Computer: " + computerChoice);

if(computerChoice < 0.33){
computerChoice = "rock";
}else if(computerChoice <= 0.67){
computerChoice = "paper";
}else{
computerChoice = "scissors";
};


#2

If it's part one of computer choice, then you only need to have first 3 lines of your code, and without any text in console.log().
Do it like this

var userChoice = prompt("Do you choose rock, paper or scissors?");
var computerChoice = Math.random();
console.log(computerChoice);

If you're having trouble with part two of computer choice exercise, again use console.log() to output the random number you've gotten first time, then once again call console.log(computerChoice) when you're if is finished to output the string representation of number that was chosen.


#3

console.log("Computer: " + computerChoice);
should be in the last line


#4

var userChoice = prompt("Do you choose rock, paper or scissors?");
var computerChoice = Math.random();
console.log (computerChoice);
if (computerChoice<0.33) {
computerChoice="rock";
} else if (computerChoice<0.66) {
computerChoice="paper";
} else {
computerChoice="scissors";
}

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

someone have a good solution??


#5

have a look at @igorcaletacar post.