 # Operators (Part 1)

There are a lot of different operators used in programming. We will take a look at some of them here.

## Assignment operators

As shown in the examples on the previous page, assignment operators are used to assign a value.

As it is said that repetition promotes understanding, let's have another look at how to use an assignment operator to assign a value to a variable named currentNumOfRainyDays:

If we wish to increment the value of the variable by 1, there are a number of ways to do so:

### + 1

We can increment the value by 1, simply by adding one to the current value:

Be aware that you have to declare the value and assign a value to it as we did in example 1.0 before we can increment the value this way.

### +=

Another way to increment the value is by using the assignment operator +=:

The + sign indicates that we take the current value of the variable and then adds whatever comes after the = sign.

### Assignment

Use console.log() to 1: log the value just after the variable has been declared and 2: to log the value right after the value of the variable has been changed.

### -=

If we want to decrement the value, we can use -= instead:

## Arithmetic Operators

Arithmetic is the study of numbers, and in connection with JavaScript the traditional arithmetic operations like addition, subtraction, multiplication and division are put into play using the signs:

• +
• -
• *
• /
• %

In addition, there are the signs ++ (incrementation) and -- (decrementation). We will get back to those later on.

### Mental arithmetic

What is the value t, u, v, x and y?

## String concatenation

When we wish to concatenate to strings, we can use the + sign as well:

The same thing applies, if the strings are stored in variables:

## String interpolation

Introduced in ES2015, string interpolation is done using template literals:

Notice 1: the use of backticks instead of normal quotation marks, and 2: that the name of the variable is wrapped in \${ }.

## Next up

In the next lesson, we will have a look at the use of conditional statements in JavaScript.

Next up: Conditional Statements