Confused #4


I'm a bit confused. How is this wrong?



Don't forget to close your else statement with curly brackets!


Thanks, I did, but it still doesn't work.




Do not use between or and keyword. They do not exist in JavaScript. Instead, use sign of comparison like:

  • if computerChoice is smaller than 0.34
  • or if computerChoice is smaller or equal to 0.67.

By the way you should set computerChoice variable to its value, not assigning a value while printing it to the console!

variableName = value;


You assign a value to a variable like this:

var fruit = "banana";

You print something to the console like this:

console.log("I am a string");



Notice how you are assigning a value to a variable inside the parentheses of console.log when you should just be putting a string or a variable there?


@thesponges @miniapple8888

It keeps telling me: Unexpected identifier 'is'. Expected ')' to end if condition.

I don't know why! I already have a ')' to end my if condition!


Hi can you post your new code?


Okay, never mind. Thanks for your help!


There are various problems with the code, but the most immediate one is that JavaScript doesn't recognise the word 'between'. If you want to check whether computerChoice is between 0 and 0.33, you have to do the following:

if (computerChoice >= 0 && computerChoice < 0.33) {
// Insert code here

This is basically checking if computerChoice is greater than or equal to 0 and less than 0.33. i.e. it's checking if computerChoice is between 0 and 0.33. && means 'and' to in the language of JavaScript. You'd have to similarly change the else if statement to get it into the correct syntax.

The second problem is that you're assigning a value to a variable inside the console.log() function. You can't do that.

Let's say your best friend is having a birthday party. You've bought them their favourite music CD as a gift. You have to ensure that when you give him/her the gift, it's already pre-packed and ready to go. You can't bring the box and the music CD separately to the front door and wrap it in front of them.

In this analogy, your best friend is a function and the gift is the input to the function. Just like you can't show up at your friend's doorstep and put the music CD in the wrapped box right there in front of them, you can't assign a value to a variable at the 'doorstep' of a function. You have to assign the value to the variable beforehand, and then give the variable to the function.

computerChoice = "paper";

Hope that helps! Programming is often frustrating at first, but keep at it, because it is also very rewarding!