Arithmetic operators
Arithmetic operators perform operations on numbers and text. You can use them in variable definitions, conditions, and actions.
| Operator | Description | Example |
|---|---|---|
| - <number> | Makes a number negative. | if there is more than one error then set 'status code' to - the number of errors; |
| <number> + <number> | Adds a number to another number. | if there is at least one additional driver then set the rental cost of the car to the base rental cost of the car + 100; |
| <number> - <number> | Subtracts a number from another number. | if the number of ’items purchased’ - the number of ’items returned’ is more than 0 then... |
| <number> / <number> | Divides a number by another number. If both numbers are integers, the result is also an integer (the result of the division without the remainder.) |
if there is at least one order then set the average order quantity to the number of items ordered / the number of orders; |
| <number> * <number> | Multiplies a number by another number. | if the price of the item * ’sales tax’ is more than 100 then... |
| <text> + <text> | Concatenates two strings. | definitions set 'full name' to ’first name’ + ’ ’ + ’last name’ |
| <number> + <text> | Concatenates a number and a string. The result is treated as a string. | if the order total is less than ’discount threshold’ then display the message: "Spend just $“ + (’discount threshold’ - order total) + ” more to receive a 10% discount!”; |
| <text> + <number> | Concatenates a string and a number. The result is treated as a string. | if the order total is more than 'discount threshold' then apply a 10% discount; display the message: "You received a 10% discount because your order was over $" + 'discount threshold' ; |