Standard math operators: +, -, *, / work with numbers
y = 3.5*x + 4;
a = (b - c)*d/4
x = x + 1
The + operator can also be used to add (concatenate) strings
Due to order of precedance use parentheses for complicated expressions
Modulus operator % returns the remainder
x = 5%3 //x will equal 2
UNARY OPERATORS
Used to increment or decrement variables
x++ and ++x are the same as x = x + 1
x-- and --x are the same as x = x - 1
x+=3 is the same as x = x + 3
EXAMPLE
Font: 8pt
12pt
20pt
24pt
Width:
Min.
50%
75%
100%
PRACTICE
Test the operators on strings (for example... alert("f"*"g"))
Create a page with two textboxes and a button. Create a function that is called on the "onclick" event of the button.
Add code to the function so that:
The contents of the textboxes are added together and displayed in an alert.
One textbox is subtracted from the other and the result displayed in an alert.
The textboxes are multiplied and the result is displayed in an alert.
The remainder of the two textboxes is displayed in an alert.
Write code that keeps track of the number of times that a user clicks on a page.