Whats wrong with my codes :(?


#1

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.67){
computerChoice"paper .";
};
else {
computerChoice= "scissors .";
};


#2

You have additional information in your string. You are looking for the pc to return "scissors ." when it is returning "scissors"
That extra little space and dot are throwing you off.

Additionally you need to add in the keyword -return-


#3

sorry but i didnt get it


#4

var compare = function(choice1, choice2) {
if(choice1 === choice2) {
return "The result is a tie";
}
};

and what about this ?


#5
else if (computerChoice<=0.67){
computerChoice"paper .";

should be

else if (computerChoice<=0.67){
          computerChoice = "paper";

There were two changes I made here. I added the = and took " ." out of the new value for computerChoice. The other two parts of your if/elseif/else statement only need the " ." removed.

Also, you'll find it more useful to log computerChoice after converting it to rock, paper, or scissors, rather than while still a number.

What are you asking about the compare function?


#6

hey thank you man very mush
the compare instructions work well ... i ve just forgot to put "!" on my sentence .
this is a weak point in this wonderfull web page ( that you need to write the same instruction as the tutor made )


#7

Also don't use semicolons after the } of your conditions that can cause errors and the reasons is explained in this post: