Logical Operators and Switch


I’m struggling with using logical operators with the switch function.

My code

It keeps telling me “unexpected token <”

Hopefully it’s obvious what I’m trying to do. I managed it with ‘if’ / ‘else’ but I can’t get it to work with switch.

I just want to check the value and make sure two things apply - Equal to or greater than X but less than Y.

Thanks in advance.


Hi welcome to the forums!

Conditionals have to have complete clauses on either side.

if (a && b)

both a and b have to be self sufficient (can evaluate to true or false by themselves).

Double check that all your conditionals follow this principle.


Thanks for your help.

I needed to repeat the variable name after &&