Welcome! Today, we will dive into the universe of JavaScript arithmetic and logical operations. Just like in math, arithmetic operations help us conduct simple calculations. Logical operations, on the other hand, allow us to evaluate conditions and make decisions. They're like controllers in a video game, deciding your character's next move based on current conditions.
So, if you were in a candy store with only $10
to spend and each candy cost $2
, what would you do? You'd likely perform a division operation to find out how many candies you could buy. But what if you wanted to buy ice cream ($4
) and chips ($3
) too with your $10
? That's where logical operations come to the fore, helping you evaluate the right decision. Let's dive in!
Arithmetic operations are pretty straightforward in JavaScript, just as they are in math. We use +
for addition, -
for subtraction, *
for multiplication, /
for division, %
for getting the remainder of the division, and finally, for power operator.
