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


My code is returning:
SyntaxError: Unexpected token <

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

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


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

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


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




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


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


Thank you all so much! It worked!


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