Should I delete the =


In the Rock Paper Scissors lesson,
is it required that I should use the = sign in:
else if(computerChoice <= 0.67) {
because every time I place a space between the less than sign and the equal sign, I get an error:
"SyntaxError: Unexpected token ="
The same thing happens in my Google Chrome browser.
The math in this code was strange because paper is between 0.34 and 0.66 (not equal to 0.67).
Should I write the code without the =?:
else if(computerChoice < 0.67) {
if the = belongs inside:
else if(computerChoice <= 0.67) {
Then what significant task does it preform?


The '=' in <= means that if computerChoice is less than and equal to 0.67. Makes sense?


but the value of paper is between 0.34 and 0.66.
How can 0.67 be equal to paper?
else if(computerChoice <= 0.67){
computerChoice = "paper";}



You're confusing yourself. :smiley:

What you are doing with:

Is that you are checking if computerChoice is lower than 0.67, but higher than 0.33, which you have probably have already made in your first if statement. computerChoice is made by using Math.floor(Math.random()), and it takes a random number between 0 and 1, and gets that number. I

IF that number is higher than 0.33 and lower than 0.67, it will change computerChoice to paper.


Got it. :sunny:
But what does the = sign mean?

else if(computerChoice <= 0.67){
computerChoice = "paper";} paper has a value between 0.34 and 0.66
else {
computerChoice = "scissors";} scissors has a value between 0.67 and 1

If I remove the = sign from:
else if(computerChoice <= 0.67){
and make it:
else if(computerChoice < 0.67){I receive the same results


My first post in this topic. Read it.


The = only makes a really small difference here. Whether you use < or <= only means that in the first case you check if the random number is smaller than 0.67, which would be the case for 0.6, 0.66, 0.669999... . Now if you add the = then you just add the 0.67 to that range of 0.34 to 0.67 that is checked. In the end the difference is 0.0.......1 (infinite 0s, then a 1). Which practically means a difference of 0. So I think that there is no real difference whether you use one or the other.


Though, I just found it strange that by using either:
< or <=
I still ended up with scissors (0.67 -- 1) being the result.
Though, in my opinion, <= should be paper because:

if(computerChoice <= 0.67){
ComputerChoice = "paper";} //true statement
ComputerChoice = "scissors";}// false statement

In which case, the console should read 0.67 as paper(true statement).
But instead, the console continues to read it as scissors (false statement):
Computer: scissors


Is your problem solved or is there still confusion about it? Also where is your case for "rock" :smile: ?


This was just a small portion I was struggling with. But to make it easier, I'm just going to call this equal sign < = a typo. Problem solved!
Thank You! :wink: