SyntaxError on step 4


#1

https://www.codecademy.com/courses/javascript-beginner-en-Bthev-mskY8/0/4?curriculum_id=506324b3a7dffd00020bf661#


SyntaxError: missing before statement trigger when i run the below code:


if (computerChoice <== 0.33){
    computerChoice = "rock";}
    else if (computerChoice >== 0.67){
        computerChoice = "scissors";}
        else {
            computerChoice = "paper";}


#2

javascript doesn't have a <== and >==, it should be: <= and >=. You do realize that between .33 and .67 now is paper, and .67 and higher is scissors?


#3

this is in JavaScript, not Python?

and the instructions state equal to or less than 0.33 is rock, greater than and equal to 0.67 is scissor, and 0.34-0.66 is paper.


#4

silly me, i was planning on saying javascript. point still stands, <== doesn't exist in javascript

then it is fine, but different. Most people do computerChoice <= .67 and then set computerChoice to paper, but methods works.


#5

not a problem at all, just like to make sure is all :slight_smile:

unfortunately making that change is still triggering the same error message when I run it... is it possible that this may be a browser or webpage issue (using Firefox)? or could there be something else hiding in the syntax do you think?


#6

Can i see an updated version of your full code?


#7

here's the code:

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

Error message reads "SyntaxError: missing before statement" still.

edit: everything above the If/if else/else statement was populated from the prior steps of the exercise.


#8

in line 1 and 2 of your code, you want to create userChoice and computerChoice variable. To assign a value to a variable, you need to use a single equal sign:

var example = "this is just an example"

3 equal signs are for comparing, not for assigning.


#9

awesome that was it! thanks so much for the help!