Using = instead of == in i
f satements. Remember that = is the assignment operator, and is used to assign values to variables. == is the equality operator, and is used to test if two expressions are equal to each other. If statement always use ==.
Putting a ; at the end of if (test);
Remember that the if statement ends after if (test) statement;
or use curly brackets if (test) { statements; }
.
Using two if
statements one after the other, instead of an if
–else
statement.
Having trouble with overly-complex conditionals which are two or more boolean expressions joined by &&
or ||
.
Not understanding that || is an inclusive-or where one or both of the operands must be true in order for the entire expression to be true.