3. Computer Choice: Part 1 = Problem

bug-reported
javascript

#1


3. Computer Choice: Part 1


Whats wrong with my code?

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


var userChoice = prompt("kamień, papier, nożyce?");

if (userChoice != "kamień" && userChoice != "papier" && userChoice != "nożyczki") 
    {
    prompt ("źle kurwa,pytanie przeczytaj, jeszcze raz, kamień,     papier, nożyce?");
    }

var computerChoice = Math.random();

if (computerChoice < 0.34) {computerChoice="kamień";
}
else if (computerChoice < 0.66) {computerChoice="papier";
}
else computerChoice="nożyczki";

console.log("a komputer wybrał " + computerChoice);


#2

It's questioning what one of your variables refer to. What does it say it should refer to? What does it refer to by the end of your code?


#3

I ran your code on https://repl.it/CrCq and it runs well. Maybe try refreshing the browser and resubmitting.


#4

I tried, I changed my browser still nothing


#5

var UserChoice = prompt ("rock, paper, scissors?");

if (UserChoice! = "stone" UserChoice &&! = "paper" UserChoice &&! = "scissors")
{
prompt ("bad, read the question, again, rock, paper, scissors?");
}

var computerChoice = Math.random ();

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

console.log ( "a computer chose" + computerChoice);


#6

For the condition inside parentheses, you should place the && operator before the 2nd and 3rd UserChoice. Also, use "rock" instead of "stone".


#7

var userChoice = prompt("rock, paper, scissors?");

if (userChoice != "rock" && userChoice != "paper" && userChoice != "scissors")
{
prompt ("Wrong");
}

var computerChoice = Math.random();

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

console.log("computer chose " + computerChoice);

still wrong:

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


#8

Try removing this section of code and submitting.


#9

var userChoice = prompt("rock, paper, scissors?");

var computerChoice = Math.random();

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

console.log("computer chose " + computerChoice);

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


#10

var userChoice = prompt("rock", "paper", "scissord");
var computerChoice = Math.random(userChoice);
console.log(computerChoice);


#11

Missing braces...

else
{
    computerChoice="scissors";
}

#12

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