Javascript Assignments

When you try to put a value in a variable you try to assign the value to the variable. To assign it, you have to use an assignment operator to get the job done. For example, use the equals to create an assignment, such as siteName = “HTMLcenter”.

Besides the equals sign, the other assignment operators serve as shortcuts for modifying the value of a variable. For example the shortcut for x = x + 5 is to use x += 5. If you don’t like the short way, just use the long version, it will not change the outcome, just a little more to type.

Assignments

ASSIGNMENT

x = y

x += y

x -= y

x *= y

x /= y

x %= y


WHAT IT DOES

Sets x to the value of y

x = x + y

x = x – y

x = x * y

x = z / y

x = x % y