Operators on Numbers
yourVar = myVar + 3;
You already know that yourVar and myVar are variable names, = is the assignment operator and 3 is a value. What about the +? This is also an operator, in this case the addition operator. In general, operators manipulate values.
How good is your arithmetic? What are the answers to 3 + 4 * 2 and 4 / 2 + 6?
If you want to avoid memorising the precedence of different operators or if you want to override the fixed precedence (for example, in the second example above, you might really want to add the 2 and 6 first), then you should use parentheses. The program will always evaluate the expression(s) in parentheses first, and where there is more than one set, the expression in the innermost pair will be evaluated first.
A binary operator on strings
The symbol + is also used as a string operator: in this context + is the operator for concatenation (appending the second string to the first). For example, 'Hello' + 'there' will give 'Hellothere'.
Question: What changes would you need to make to the two strings in the example above so as to obtain the result 'Hello there'?
Remember that a string can contain spaces. So there are two possible solutions:
'Hello ' + 'there'
(where the first string consists of the letters h, e, l, l, o followed by a space character, and the second string is as above), or
'Hello' + ' there'
(where the first string is as above and the second string consists of a space character followed by the letters t, h, e, r, e).
The next article we recommend you look at is 'Getting Data From a User and Displaying Results'.