The divide (
/) operator allows you to divide two numbers and get their quotient.
number / number divide(number, number) number.divide(number)
/ operator follows the standard mathematical order of operations (PEMDAS). For more detail, see Operator Precedence.
You can also use the function version,
12 / 4 /* Output: 3 */ divide(12, -4) /* Output: -3 */ 12.divide(4) /* Output: 3 */
Since divide is a binary operator, it can only work on two operands – the objects which are being operated on (if – the ternary operator – is the only operator that works on three operands).
If you need to work with more than two operands, the shorthand
/ is by far the easiest way to do it.
40 / 2 / 5 /* Output: 4 */ divide(divide(40,2),5) /* Output: 4 */ 40.divide(2).divide(5) /* Output: 4 */
The example database below shows the per-person split for several heists carried out by a certain crew of classy thieves. The simple Split formula shows the
/ operator in action, and simply divides Total by Shares.
prop("Total") / prop("Members").length()
Instead of using hard-coded numbers, I’ve called in each property using the