I cant get over this issue-Did you set var computerChoice = Math.random() ? The capital 'M' in 'Math' is important! somebody help plz asap


#1

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

if (computerChoice < 0.33) {
computerChoice = ("rock");
} else if(computerChoice <= 0.66) {
computerChoice = ("paper");
} else {
computerChoice = "scissors";
} console.log("Computer: " + computerChoice);

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";
}
}
else if(choice1 === "scissors") {
if(choice2 === "rock") {
return "rock wins";
}
else{
return "scissors wins";
}

}

}


#2

Is there something you would like to ask? There's nothing to answer here!


#3

when i run the code it tells me that did you set var compterchoice=math.random().i cant get over it


#4

Looks like you typo'd the name when you explained what's wrong, is the name completely correct in the code? Capitalization and all?

And does the code actually finish running, or does it crash? Are there error messages in the console window? If so, you have to deal with those first, always, you don't want your code to crash, that can't be right.

If you're not getting enough feedback about how it acts correctly, then try using your own code, see if it does the things that the instructions describe.

What value do the instructions say that computerChoice should have? What value does it have when your code has finished?


#5

ya i have taken care of all typo'd mistakes capitallization and all,like it tells to make the capital M in math.random,i have done that also,but when i click on submit button a pop up come out tells me did you set var compterChoice=Math.random().


#6

print out the value of computer choice, is that something that Math.random would produce?


#7

i have tried with printing the o/p
console.log(computerChoice).but same error :frowning:


#8

if (computerChoice < 0.33) {
computerChoice = ("rock");
} else if(computerChoice <= 0.66) {
computerChoice = ("paper");
} else {
computerChoice = "scissors";
} console.log("Computer: " + computerChoice);

the brackets around the first and second string shouldn't be there
if (computerChoice < 0.33) {
computerChoice = "rock"; <---- no brackets
}


#9

You change the value to a string, it's supposed to be a number 0.0-1.0


#10

it didnt solved my problem


#11

for which should i change the value ?


#12

if it doesn't solve the problem for you, you're either not doing something right or you should try changing browsers, i tried it myself and just removing the brackets around

if (computerChoice < 0.33) {
computerChoice = ("rock");
} else if(computerChoice <= 0.66) {
computerChoice = ("paper");
} else {
computerChoice = "scissors";
} console.log("Computer: " + computerChoice);

the first two and it worked almost like a charm, the only issue is the first couple of lines where you're defining userchoice


#13

This is what codecademy does when checking your code. Part of it, anyway:

if (typeof computerChoice !== 'number') {
  return "Did you set var computerChoice = Math.random() ? The capital 'M' in 'Math' is important!";
}

Which means that it'll be triggered if computerChoice is anything other than a number, so you may not assign a string to that name, not in this exercise anyway

On the next one they do ask you to assign a string to that name, but you're getting ahead of yourself somehow.


#14

My choice was rock and this went by the chance rather... it's a bit strange, I am sure there are some mistakes:


#15

Actually, mistaken 'return' must be changed to 'computerChoice':


#16

Just from the help of the next lesson I have relised my real mistake and computer finaly did its own choice :smile:


#17

so what should i do :frowning:


#18

Eyy we went over this. Don't assign to computerChoice in that exercise, because it is supposed to be a number.
Click the reset button on the exercise and only do what it says