HTML and CSS Reference
can be performed on both numbers and
strings and one of the operands is a string.
The multiplication operation can only be
used with numbers, so the strings are con-
verted automatically to numbers.
The automatic conversion of numbers to strings can lead to some
unexpected and unwanted behavior, or bugs in programmer parlance, in
you'll learn how to force your operand to be a number.
Comparisons are operators that produce a true or false value, otherwise
known as a Boolean value. Comparison operators are crucial when it
comes to branching and looping (see “Branching and looping”). There
are general-purpose comparison operators as well as several operators
that are intended for Boolean values. The three main Boolean opera-
tors are as follows:
Returns true if both oper-
ands are true
Returns true if either oper-
and is true
Returns true if its operand
Experiment with these operators in the
console until you're comfortable with these