Syntax Error on Rock Paper Scissors 4. Computer Choice: Part 2


#1

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

My code is returning:
SyntaxError: Unexpected token <

var userChoice = prompt("Do you choose rock, paper, or scissors?");
var computerChoice = Math.random();
console.log(computerChoice);
if(computerChoice =< .33 ){
  computerChoice = "rock"; 
}
 else if (computerChoice =< .66) {
     computerChoice = "paper";
 }
 else {
     computerChoice = "scissors";
 }


Not sure what I'm doing wrong. Any ideas?


#2

if(computerChoice =< .33 )  //   >=  greater than or equal to

else if (computerChoice =< .66) // same

#3

What @rcodeman is trying to say is that there is a syntax issue. The = always comes last in an inequality operator.

<=

>=

Addendum

The browser supports the 2015 release of ECMAScript. None of the older lesson authors could have foreseen this. The version expected is pre-2015. Here is what putting an = first does in the new syntax:

b = a => a * a;

console.log(typeof b);       // function

which means we can invoke it.

console.log(b(5));           // 25

console.log(b(6 * 7));       // 1764

We can also inspect it...

console.log(b.toString());   // a => a * a

#4

Aside from the above post, consider the use of dot in a number. What number begins with dot? None. dot is not a number. Granted, the browser may support it, given the frequency at which it is being expected to, but it still presents as a potential tripwire down the road. A proper number, when between -1 and 1 is written with a zero preceding the dot.

  0.33
- 0.66

#5

Thank you all so much! It worked!


#6

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