4 build "Rock, Paper, Scissor" part 2


#1

HOLA, HI

So I have a lot of time trying to see what is wrong with my code, it says sintax error and I can't see why... help me a bit.

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

if (computerChoice <= 0.33); {
    computerChoice = "Rock";
} else if (computerChoice >= 0.34 && computerChoice <= 0.66); {
    computerChoice = "Paper";
} else { 
    computerChoice "scissors";
};

Syntax error.>



#2

Neither of these semicolons are supposed to be there.


#3

the syntax for an if/else if/ else statement is as follows

if(){

} else if(){

}else{

};

If you want you could save this and re-use it whenever you want just for reference.


#4

Awesome, thank you! So blind


#5

haha don't worry about it. its actually really common.


#6

Do you have a system or methood for a code's review? cause I spend a lot of time Reading it and couldn't see it... what is the first thing you look for in a code?


#7

well if your code doesn't work check the error, they are usually accurate. but if the error says something like syntax error, then it might include a symbol and just look at all of those symbols and see if anything is out of order. syntax is really important, that is why I sent the syntax for if/else if/ else statements. sometimes if there is a comment you have to make sure they end and don't cancel out important code. also check your strings and make sure they match exactly what the instructions say. just the basics of my method. sometimes you can spend hours looking for the one wrong character that stops the whole program.


#8

the most common mistakes are the if statement syntax and the function syntax. Almost every one has problems with syntax at some point.


#9

Thank you, I really appreciate it... I hope to become good at this (y)


#10

I hope you stick through it. ive been learning this language for two years now and I just barely feel like I am good enough to help some people out. I still am not fluent but I get around alright.


#11

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