4 build "Rock, Paper, Scissor" part 2



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.>


Neither of these semicolons are supposed to be there.


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


} else if(){



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


Awesome, thank you! So blind


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


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?


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.


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


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


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.


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